显示java.lang.NullPointerException

时间:2011-03-15 12:21:43

标签: android

CustomDialogExample.java

public class CustomDialogExample extends Activity {
     /** Called when the activity is first created. */


        @Override
        public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           /** Display Custom Dialog */
           CustomizeDialog customizeDialog = new CustomizeDialog(this);
           customizeDialog.show();
        }
    }

CustomizeDialog.java

public class CustomizeDialog extends Dialog implements OnClickListener {
Button okButton;

public CustomizeDialog(Context context) {
super(context);
/** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
requestWindowFeature(Window.FEATURE_NO_TITLE);
/** Design the dialog in main.xml file */
setContentView(R.layout.main1);
okButton = (Button) findViewById(R.id.OkButton);
okButton.setOnClickListener(this);
}


@Override
public void onClick(View v) {
/** When OK Button is clicked, dismiss the dialog */
if (v == okButton)
dismiss();
}

}

这是我想要从服务中调用的活动代码....

1 个答案:

答案 0 :(得分:0)

您应该在AndroidManifest.xml中提到CustomDialogExample活动,如下所示:

<activity android:name=".CustomDialogExample" android:label="Dialog Example"
                  android:theme="@android:style/Theme.NoTitleBar" />