开发者

java.lang.NullPointerException

开发者 https://www.devze.com 2023-02-16 18:39 出处:网络
CustomDialogExample.java public class CustomDialogExample extends Activity { /** Called when the ac开发者_如何学Gotivity is first created. */

CustomDialogExample.java

public class CustomDialogExample extends Activity {
     /** Called when the ac开发者_如何学Gotivity 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();
}

}

this is code of my activity to which i want to call from service ....


You should have CustomDialogExample activity mentioned in your AndroidManifest.xml, like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消