I had added a dialog in the Activity
private static EditText Red;
private static EditText Green;
private static EditText Blue;
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
extras = getIntent().getExtras();
mImagePSView = new ImageDrawView(this, extras);
setContentView(R.layout.layout1);
}
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, MENU_CREAT, R.string.menu_create);
return true;
}
public boolean onOptionsItemSelected(Menu.Item item) {
switch (item.getId()) {
case MENU_CREAT:
CreateDialog();
return true;
return super.onOptionsItemSelected(item);
}
public void CreatePalette()
{
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.layout2);
dialog.setTitle("Set RGB");
Red = (EditText)findViewById(R.id.red);
Green = (EditText)findViewById(R.id.green);
Blue = (EditText)findViewById(R.id.blue);
Button button = (Button)findViewById(R.id.palette_ok);
if (button == null)
{
Paledialog.show();
return;
}
button.setOnClickListener(mPaleOkListener);
button = (Button)findViewById(R.id.palette_cancel);
button.setOnClickListener(mPaleCancelListener);
dialog.show();
}
layout1.xml is a normal layout
layout2.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="70dip"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView id="@+id/labelred"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Red:"/>
<TextView id="@+id/labelgreen"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft = "@+id/green"
android:layout_alignTop="@+id/labelred"
android:text="Green:"/>
<TextView id="@+id/labelblue"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft = "@+id/blue"
android:layout_alignTop="@+id/labelred"
android:text="Blue:"/>
<EditText id="@+id/red"
android:layout_width="50dip"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_below="@id/labelred"/>
<EditText id="@+id/green"
android:layout_width="50dip"
android:layout_height="wrap_content"
android:layout_toRight = "@+id/red"
android:layout_alignTop="@id/red"
android:background="@android:drawable/editbox_background"/>
<EditText id="@+id/blue"
android:layout_width="50dip"
android:layout_height="wrap_content"
android:layout_toRight = "@+id/green"
android:layout_alignTop="@id/red"
android:background="@android:drawable/editbox_background"/>
<Button id="@+id/palette_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/red"
android:layout_alignParentRight="true"
android:text="OK" />
<Button id="@+id/palette_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeft="@+id/palette_ok"
android:layout_alignTop="@+id/palette_ok"
android:text="Cancel" />
</RelativeLayout>
Follow the code i can create the dialog and display it
but used Red = (EditText)findViewById(R.id.red);
the findViewById can't find the View, the red is null
the all findViewById are null, i don't know why the view is null
Please help me , thanks


