Here is how I do it... _______________________________________ AlertDialog.Builder builder;
Context mContext = getApplicationContext(); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.widget_icon_selection, (ViewGroup) findViewById(R.id.layout_root)); builder = new AlertDialog.Builder(this); builder.setView(layout); ImageView torch = (ImageView)layout.findViewById(R.id.img_torch_setting); torch.setOnClickListener(new OnClickListener(){ @Override public void onClick(View view) { // Do whatever when the button is clicked. alertDialog.dismiss(); } }); alertDialog = builder.create(); alertDialog.show(); _____________________________________ Ryan On Thu, Dec 17, 2009 at 12:25 PM, roly <o.gonth...@gmail.com> wrote: > Hi, > I have created a custom (alert)dialog based on a layout, which > contains some buttons. > I'd like to listen these buttons, so I tried doing a simple > OnclickListener but it crashes... I think this happens since at start > he tries to listen a element which is not displayed. No ? > > Is there anybody who has encounter this problem ? > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en