unable to Print custom Listview data in android -
public class setting extends activity implements onclicklistener { listview listview1; imageview backbutton; arraylist<notify> web = new arraylist<notify>(); list<string> places = arrays.aslist("item1", "item2", "item3", "bing", "itunes", "wordpress", "drupal", "item1", "item2", "item3", "bing", "itunes", "wordpress", "drupal", "item1", "item2", "item3", "bing", "itunes", "wordpress", "drupal"); @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.setting); listview1 = (listview) findviewbyid(r.id.listview1); backbutton = (imageview) findviewbyid(r.id.backbutton); backbutton.setonclicklistener(this); customlist adapter = new customlist(setting.this, web); listview1.setadapter(adapter); } @override public void onclick(view v) { // todo auto-generated method stub if (v.getid() == r.id.backbutton) { finish(); } } }
here custom listview:
public class customlist extends baseadapter { private final activity context; arraylist<notify> web; public customlist(activity context, arraylist<notify> web) { super(); this.context = context; this.web = web; } @override public view getview(int position, view view, viewgroup parent) { layoutinflater inflater = context.getlayoutinflater(); view rowview = inflater.inflate(r.layout.settingrowitem, null, true); textview txttitle = (textview) rowview .findviewbyid(r.id.rowcontact_txtname); txttitle.settext(web.get(position).getweb()); // imageview.setimageresource(imageid[position]); return rowview; } @override public int getcount() { // todo auto-generated method stub return 0; } @override public object getitem(int arg0) { // todo auto-generated method stub return null; } @override public long getitemid(int arg0) { // todo auto-generated method stub return 0; } }
notify.java class contain:
private string web; public string getweb() { return web; } public void setweb(string web) { this.web = web; }
}
i trying display data in list view don't know doing mistake have change string array array list can display text displaying blank item please me , tell doing mistake . able print data when extend custom adapter array adapter while want display list view item using extending base adapter please tell me , wrong
follow steps if want listview
working
create constructor
in notify model like
private string web; public notify(string web){ this.web=web; } //and getter / setter methods
now, implement in activity
like
list<notify> web = new arraylist<notify>(); web.add(new notify("item1")); web.add(new notify("item2")); web.add(new notify("item3")); web.add(new notify("item4")); web.add(new notify("item5")); customlist adapter = new customlist(setting.this, web);
now, adapter
seems like.
public class customlist extends baseadapter { private final activity context; priavte list<notify> web; public customlist(activity context, list<notify> web) { super(); this.context = context; this.web = web; } @override public view getview(int position, view view, viewgroup parent) { layoutinflater inflater = context.getlayoutinflater(); view rowview = inflater.inflate(r.layout.settingrowitem, null, true); textview txttitle = (textview) rowview .findviewbyid(r.id.rowcontact_txtname); txttitle.settext(web.get(position).getweb()); // imageview.setimageresource(imageid[position]); return rowview; } @override public int getcount() { // todo auto-generated method stub return web.size(); } @override public object getitem(int position) { return web.get(position); } @override public long getitemid(int id) { // todo auto-generated method stub return id; } }
Comments
Post a Comment