android - Error: hide list View child Item -
i have listview childitems.when press listview child item's got imageview when press on want remove expandable listview item.please find below code snipped used.
code snippet used hide list item
expandablelistview remov = (expandablelistview) v.findviewbyid(r.id.lvexp); remov.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { // todo auto-generated method stub removimg.setonclicklistener(new onclicklistener() { @suppresslint("newapi") @override public void onclick(view v) { // todo auto-generated method stub toast.maketext(v.getcontext(), "hello", toast.length_short).show(); addcadschildadoptor.remove(1); addcadschildadoptor.notify(); } }); return false; } }); return v; }
i used expandable list adopter snippet
@suppresslint("newapi") private void preparelistdata() { listdataheader = new arraylist<string>(); listdatachild = new hashmap<string, list<string>>(); listdataheader.add(""); addcadschildadoptor = new arraylist<string>(); if(cardnameone!="") { addcadschildadoptor.add(cardnameone); } if(cardnametwo!="") { addcadschildadoptor.add(cardnametwo); } toast.maketext(getactivity(), cardnametwo, toast.length_long).show(); listdatachild.put(listdataheader.get(0), addcadschildadoptor); listadapter = new expandablelistadapter(getactivity(), listdataheader,listdatachild); explistview.setadapter(listadapter); }
error log
04-04 16:47:51.611: e/inputeventreceiver(13452): exception dispatching input event. 04-04 16:47:51.626: e/messagequeue-jni(13452): exception in messagequeue callback: handlereceivecallback 04-04 16:47:51.696: e/messagequeue-jni(13452): java.lang.nullpointerexception 04-04 16:47:51.696: e/messagequeue-jni(13452): @ com.comparecr.listvcompare$4.ontouch(listvcompare.java:720) 04-04 16:47:51.696: e/messagequeue-jni(13452): @ android.view.view.dispatchtouchevent(view.java:7374) 04-04 16:47:51.696: e/messagequeue-jni(13452): @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2464) 04-04 16:47:51.696: e/messagequeue-jni(13452): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2197) 04-04 16:47:51.696: e/messagequeue-jni(13452): @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup. java:2470) 04-04 16:47:51.696: e/messagequeue-jni(13452): @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2169) 04-04 16:47:51.696: e/messagequeue-jni(13452): @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2470)
you using wrong function.
public final void notify ()
added in api level 1 causes thread waiting on object's monitor (by means of calling 1 of wait() methods) woken up. if more 1 thread waiting, 1 of them chosen @ discretion of vm. chosen thread not run immediately. thread called notify() has release object's monitor first. also, chosen thread still has compete against other threads try synchronize on same object.
instead of notify(), need use
addcadschildadoptor.notifydatasetchanged();
also, instead of using .setonclicklistener() on view, should use .setonitemclicklistener() gives. information position of item in list. @ reference more info
Comments
Post a Comment