After replacing getApplicationContext() with "this", I am still having the same problem.
Any ideas? Thanks! On Feb 9, 3:02 am, TreKing <treking...@gmail.com> wrote: > DO NOT use getApplicationContext(), use *this*. > > > > On Sat, Feb 6, 2010 at 10:59 PM, YCH <yip....@gmail.com> wrote: > > Hi, > > > I am new to android development and is having some problems on showing > > a custom dialog. My development environment is sdk 1.5 with eclipse. > > > In the menu, if user click on the first button, I want to show a > > dialog. > > > public boolean onOptionsItemSelected(MenuItem item) { > > switch (item.getItemId()) { > > case MENU_ADD > > this.showDialog(1); > > return true; > > case MENU_QUIT : > > this.finish(); > > return true; > > } > > return false; > > } > > > protected Dialog onCreateDialog(int id) { > > Dialog dialog; > > switch(id) { > > case 1: > > dialog = new Dialog(this.getApplicationContext()); > > dialog.setContentView(R.layout.input_dialog); > > TextView t = (TextView) > > dialog.findViewById(R.id.TextView01); > > Button b = (Button) dialog.findViewById(R.id.Button01); > > break; > > default: > > dialog = null; > > } > > return dialog; > > } > > > I know that the showDialog() will go to onCreateDialog(), but when I > > try to execute it in the emulator, it keeps saying that ERROR/ > > AndroidRuntime(789) at the line this.showDialog(1); > > > Is there anything important things missed? Would be grateful if there > > is some ideas on it! > > > Thanks, > > YCH > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > > ------------------------------------------------------------------------------------------------- > TreKing - Chicago transit tracking app for Android-powered > deviceshttp://sites.google.com/site/rezmobileapps/treking -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en