android - How to add onclicklistener to dynamically generated text views -


i have dynamically created textviews in application. want give on click event textviews.. when click on textview, need id of textview..

you try following code.

textview text = new textview(this);      text.settext("text here");     ll.addview(text);     text.setonclicklistener(new onclicklistener() {          @override         public void onclick(view arg0) {             // todo auto-generated method stub             toast.maketext(getapplicationcontext(), "id : "+arg0.getid(), toast.length_short).show();         }     }); 

in "ll" layout add textview , after adding put clicklistener() click event.

hope useful you.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -