java - From a class, call a function from an activity -


i have made class(paperclip), makes custom dialogbox appear on screen. on activity create instance of paperclip , make dialogbox show on activity. want when button pressed, code on activity executed. want code executed activity, because want dialog box can reuse on lots of different activities within project.

i thinking of making variable in class, , attach listener on activity. way, or there easier solution?

public class paperclip {     int = 0;     dialog mydialog;     textview t;     int mid;     context context2;      public paperclip(context context) {         super();         context2 = context;     }      public void showit(final string[] messages) {         final int lengte = messages.length;          mydialog = new dialog(context2, r.style.customdialogtheme);         mydialog.setcontentview(r.layout.messagebox);         t = (textview) mydialog.findviewbyid(r.id.message);         if (lengte != 0) {             if (i < lengte) {                 t.settext(messages[i]);                 i++;             }             button iets = (button) mydialog.findviewbyid(r.id.mbja);             iets.setonclicklistener(new view.onclicklistener() {                  public void onclick(view v) {                     if (i < lengte) {                         t.settext(messages[i]);                         i++;                     } else{                         t.settext("ik hoop dat deze informatie nuttig was. klik op ja om alles opnieuw te horen.");                         = 0;                     }                  }             });         }         button iets2 = (button) mydialog.findviewbyid(r.id.button2);         iets2.setonclicklistener(new view.onclicklistener() {              public void onclick(view v) {                 mydialog.dismiss();             }         });          button iets3 = (button) mydialog.findviewbyid(r.id.button3);         iets2.setonclicklistener(new view.onclicklistener() {              public void onclick(view v) {                 //todo: execute code activity here.             }         });          mydialog.show();     } } 

thanks!

you must create instance of dialogbox button in activity , add listener event , post code inside listener


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -