This is the code i have used for the menu item selection:
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_settings:
showDialog(1);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
There is only one option in the menu, and i have designed a customDialog using the following code:
protected Dialog onCreateDialog(int id) {
Context mContext = getApplicationContext();
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("About Us");
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("App Created By: Prateek Garg (garg.prateek1@gmail.com)");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.logo_resumes);
return dialog;
}
}
The problem is that whenever i press the menu item "About Us", the app force-closes itself. I am unable to rectify whatever error there is, but i am hoping you guys can.
Thanks in advance. PS. I have created the menuInflator() in onCreateOptionsMenu() .
Cheers
LOGCAT shows the following errors: [I donot know how to understand or remove them... :( ]
07-27 23:35:04.569: W/dalvikvm(648): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
07-27 23:35:04.659: E/AndroidRuntime(648): FATAL EXCEPTION: main
07-27 23:35:04.659: E/AndroidRuntime(648): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
07-27 23:35:04.659: E/AndroidRuntime(648): at android.view.ViewRootImpl.setView(ViewRootImpl.java:589)
07-27 23:35:04.659: E/AndroidRuntime(648): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:326) and a lott more .
If you guys say so, i'll include the rest errors too, but i think they are just forming because of the first 1 or 2 as is the case generally