i developing android app in there 2 list views. when user clicks on items of first list view must added second list view. have implemented correctly. problem strings must not repeated in second list view. means if string there in list view 1 , click on it, moves list view 2 , if again click on string a, should prompt message(message handled me). here code. missing?
arraylist<string> arr2; arrayadapter<string> adapter2; arr2 = new arraylist<string>(); lv1.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view arg1, int arg2, long arg3) { string selected = lv1.getitematposition(arg2).tostring(); arr2.add(selected); adapter2 = new arrayadapter<string>(getbasecontext(), android.r.layout.simple_list_item_1, arr2); lv2.setadapter(adapter2); adapter2.notifydatasetchanged(); } });
probably work.
string selected = lv1.getitematposition(arg2).tostring(); if (!arr2.contains(selected)) { //add item in second listview arr2.add(selected); } else { show popup }
Comments
Post a Comment