android - How to add a listener to a button - not from activity class -


i have button set in xml so:

  <button     android:id="@+id/button1"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:gravity="center"     android:text="@string/playervicesbutton" /> 

it's part of simple alert dialogue display error message (i used rather simple '.setneutralbutton' because have more control on it's appearance way).

i'm having lot of problems dismissing dialogue when button pressed.

the problem not invoking activity class, if use following in xml:

android:onclck="dismissdialog" /> 

the dismissdialog(view myview) method has in main activity class correct? , main activity class not have visibility of dialogue it's created, held , called different class.

again, can't use either:

button btn = (button) findviewbyid(r.id.dismissbutton); 

because class doesn't have access findbyview

so how can dismiss dialogue using button defined in xml?

(i've looked over, examples assume button created in, , called main activity class - code has 55 classes , lot of stuff happens away / detached activity class.

i'm not familiar dialogues , xml - code (apart 1 alertdialog) purely opengl - appreciated


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -