Sunday, 15 August 2010

Android java.lang.IllegalStateException on ListView -



Android java.lang.IllegalStateException on ListView -

i utilize listactivity specialadapter show log information. not utilize background thread error when scroll list:

java.lang.illegalstateexception: content of adapter has changed listview did not receive notification. create sure content of adapter not modified background thread, ui thread. [in listview(16908298, class android.widget.listview) adapter(class ru.foxgsm.ui.debugactivity$specialadapter)]

please, help me.

(foxlog static class log information, perhaps thread. in list want show foxlog snapshot)

public class debugactivity extends listactivity { private class specialadapter extends baseadapter { private layoutinflater minflater; public specialadapter(context context) { super(); // cache layoutinflate avoid asking new 1 each time. minflater = layoutinflater.from(context); } public int getcount() { homecoming foxlog.count(); } public long getitemid(int index) { homecoming index; } public object getitem(int index) { homecoming foxlog.get(foxlog.count()-index-1); } // type of view public view getview(int position, view convertview, viewgroup parent) { textview text; if (convertview == null) { convertview = minflater.inflate(r.layout.debug_list, null); text = (textview)convertview.findviewbyid(r.id.text); convertview.settag(text); } else text = (textview) convertview.gettag(); string s = (string) getitem(position); if (s==null) homecoming convertview; text.settext(s); boolean iserror = false; if (s!=null && s.length()>0) { string prefix = s.substring(0, 1); if (prefix.equals("e") || prefix.equals("w")) iserror = true; } if (iserror) text.setbackgroundresource(r.color.red); else text.setbackgrounddrawable(null); homecoming convertview; } } private void refreshdata() { foxlog.reinit(this); specialadapter adapter = (specialadapter)this.getlistadapter(); adapter.notifydatasetchanged(); } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.debug); foxlog.reinit(this); specialadapter adapter = new specialadapter(this); setlistadapter(adapter); button mexit = (button)findviewbyid(r.id.exit); mexit.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { finish(); } }); } }

java android

No comments:

Post a Comment