Getting text from Dynamically created button :Android -


i created buttons dynamically, assigned url address obtained handlers settext(). not able text of button,if clicked,since arg.gettext() not working in onclicklistener. there way text of button created dynamically

      ( = 0; <itemlist.gettitle().size()-1; i++) {     title[i] = new textview(this);     title[i].settextcolor( -16711936 );     title[i].settextsize(18);     title[i].settext("title = "+itemlist.gettitle().get(i));     description[i] = new textview(this);     description[i].settextcolor(-16776961);     description[i].settext("description = "+itemlist.getdescription().get(i)+"......");     more[i]=new button(this);     more[i].settext(itemlist.getlink().get(i));           layout.addview(title[i]);     system.out.println("title view set");     layout.addview(description[i]);     //system.out.println("description view set");     layout.addview(more[i]);         more[i].setonclicklistener(listener);   }  private onclicklistener listener=new onclicklistener(){      public void onclick(view arg) {         // todo auto-generated method stub           string value=(should text of selected button)                } 

any appreciated.

the view in onclick() button.

just downcast it:

button btn = (button) arg; string btntext = btn.gettext(); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -