Call the setOnClickListener method on the Button instance that you got
from findViewById, just like you do for the TextView. Both classes
subclass View, so they both have that method. Inside the method you
call dismissDialog, which is available via the enclosing Activity,
just like you call showDialog in the TextView's listener.

On Mar 17, 5:53 pm, Lazarus <laza...@gmail.com> wrote:
> Hi All,
> I can't dismiss my custom dialog.
> I have XML layout with some text, pic and a button for dismissing the
> dialog.
> My onCreateDialog starts a DatePicker Dialog and About Dialog
>
> @Override
>         protected Dialog onCreateDialog(int id) {
>                 switch (id) {
>                 case DATE_DIALOG_ID:
>                     ........................works nice
>                     ........................
>                 case ABOUT_DIALOG_ID:
>
>                         Dialog dialog = new Dialog(this);
>
>                         dialog.setContentView(R.layout.custom_dialog);
>                         dialog.setTitle("About mySelf");
>
>                         TextView text = (TextView)
> dialog.findViewById(R.id.lblAbout);
>                         text.setText(R.string.cd_about);
>                         ImageView image = (ImageView)
> dialog.findViewById(R.id.imgLomaryn);
>                         image.setImageResource(R.drawable.lomaryn);
>                         Button cdBack = (Button)
> findViewById(R.id.cdbtnCancel);
>                some help needed here (?)
>                         return dialog;
>                 }
>                 return null;
>
> }
>
> To show the Custom Dialog I click on textview as follows
>
> // add a click listener to lblTitle label
>
>         mlblTitle.setOnClickListener(new View.OnClickListener() {
>
>                         public void onClick(View v) {
>                                 showDialog(ABOUT_DIALOG_ID);
>                         }
>                 });
>
> I need the click on my cdBack button to dismiss the Custom Dialog
> There are not many methods available for Custom Dialogs. Even
> setButton method is missing. It is for AlertDialogs only
> Can't cast the setOnClickListener for the Custom Dialog
>
> Thanks for any valuable help

-- 
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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to