android - How can I select multiple textViews from the collection of textViews which is not in listview on long pressing -
i have collection of textviews
in linearlayout
, want them select on long press. tried code didn't work...
textview.setonlongclicklistener(new view.onlongclicklistener() { @override public boolean onlongclick(view v) { // todo auto-generated method stub textview.setselected(true); selected = 1; return false; } }); textview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if(selected == 1){ if(textview.getselected()) textview.setselected(false); else textview.setselected(true); } } });
i tried search setonlongpresslistener
didn't find that. please suggest me methods action want.
i assume want highlight textview when selected on long press. try this:
textview.setonlongclicklistener(new view.onlongclicklistener() { @override public boolean onlongclick(view view) { boolean selected = !view.isselected(); view.setselected(selected); view.setbackgroundcolor(selected ? color.red : color.transparent); return true; } });
Comments
Post a Comment