android - Getting information of Button on click -


i have map<string, string> stores id , name. creating buttons map, button text set name. how can information of button on click event? say, want id when button clicked.

please note id unique, name can duplicated.

i have tried setting sethint(id) button while creation. but, don't find gethint() method on view under onclick().

you store id in tag property of button , retrieve gettag()

e.g.

button b=new button(); b.settag(yourid);  b.setonclicklistener(new view.onclicklistener() {     @override     public void onclick(view v) {         log.i("tag", "my tag " + v.gettag());     } }); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -