Android List View Item is not working correctly -
i trying show view form listviewitem, when checked item listitems not working. here code below using.
public class contentlist<view> extends listactivity { string [] list = {"list item 1","list item 2","list item 3"}; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_content_list); listview lstview = getlistview(); lstview.setchoicemode(listview.choice_mode_multiple); lstview.settextfilterenabled(true); setlistadapter(new arrayadapter<string> this, android.r.layout.simple_list_item_checked,list)); } public void onlistitemclick(listview parent, view v,int pos, long id){ checkedtextview item = (checkedtextview) v; toast.maketext(this, list[pos] + "checked : "+ !item.ischecked(), toast.length_long).show(); } }
i see 2 problems , both toast
:
- since in
onclick()
, instead ofthis
context
shouldcontentlist.this
- the second
param
ofmaketext()
takes eithercharsequence
orint
haveboolean
in thereischecked()
need determine should before line , use "true" or "false" or whatever want needscharsequence
if these don't fix problem please state exact problem , if crashing post logcat.
Comments
Post a Comment