java - Retrieving the text of a custom listview from textview -
i have following code displays menu if long pressed on listview:
@override public void oncreatecontextmenu(contextmenu menu, view v, contextmenuinfo menuinfo) { if (v.getid()==r.id.lvfiles) { adapterview.adaptercontextmenuinfo info = (adapterview.adaptercontextmenuinfo)menuinfo; menu.setheadertitle("what do?"); string[] menuitems = getresources().getstringarray(r.array.menuselect); (int = 0; i<menuitems.length; i++) { menu.add(menu.none, i, i, menuitems[i]); } } } @override public boolean oncontextitemselected(menuitem item) { adapterview.adaptercontextmenuinfo info = (adapterview.adaptercontextmenuinfo)item.getmenuinfo(); int menuitemindex = item.getitemid(); string[] menuitems = getresources().getstringarray(r.array.menuselect); string menuitemname = menuitems[menuitemindex]; textview ck = (textview) mframe4.findviewbyid(r.id.txttitle); toast.maketext(getactivity(), string.format("selected %s , %s", menuitemname, ck.gettext().tostring()), 2000).show(); return true; }
my custom listview calls layout has textview. how display value of text of selected list listview?
toast.maketext(getactivity(), string.format("selected %s , %s", menuitemname, display text of selected textview, 2000).show();
you can text of textview
using following code:
string txt = ((textview) info.targetview.findviewbyid(r.id.txttitle)).gettext().tostring();
Comments
Post a Comment