android - Set listview single item can be clicked at a time -
this listview. have used code clicked position of row. when i'm clicking on more item @ same time, app crashes. understand why. how set list.setchoicemode(listview.choice_mode_single) piece here? i'm using arraylist item position , not list item position. please help.
public void onitemclick(int mposition) { listmodel tempvalues = customlistviewvaluesarr.get(mposition); totalwords = integer.parseint(tempvalues.gettextwords2()); string statusbarpercentage=tempvalues.gettextpercentage(); int pos = mposition + 2; intent intent = new intent(getapplicationcontext(), find.class); intent.putextra("wordlength", pos); // parameters startactivity(intent); }
this code i've written take position listview.
adapter class:
public class customadapter extends baseadapter implements view.onclicklistener { //--------------code------------ /** * ****** called when item click in listview *********** */ private class onitemclicklistener implements view.onclicklistener { private int mposition; onitemclicklistener(int position) { mposition = position; } @override public void onclick(view arg0) { mainactivity sct = (mainactivity) activity; sct.onitemclick(mposition); } } //-----------code etc----- }
try this:
listview.setchoicemode(listview.choice_mode_single);
Comments
Post a Comment