我正在使用这个文件来选择颜色,它是一个不错的对话框,我正在使用以下代码
public class Main extends Activity implements
ColorPickerDialog.OnColorChangedListener {
Button b;
Context c = this;
ColorPickerDialog.OnColorChangedListener cc;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
new ColorPickerDialog(c, cc, "tag", 16777215, 0).show();
}
});
}
@Override
public void colorChanged(String key, int color) {
Log.d("debug", "key is " + key + " color is " + color);
}
}
在我main.xml
那里只有一个按钮。当我单击一个按钮并出现对话框时,此代码工作正常,但是当我选择一种颜色时NullPointerException
,我不知道为什么,任何帮助将不胜感激。问候