android - Custom ListView item ids -
i'm trying make activity setting option of application, , use custom listview 3 different type of view, code of custom listview:
public class customlistadapter extends arrayadapter<string>{ string[] text; context context; checkbox chkbox; public customlistadapter(activity context, string[] text){ super(context, r.layout.layout_checkbox, text); this.text = text; this.context = context; } @override public view getview(int position, view convertview, viewgroup parent){ view single_row = null; if(position<4){ layoutinflater inflater = (layoutinflater)context.getsystemservice(context.layout_inflater_service); single_row = inflater.inflate(r.layout.layout_checkbox, null, true); textview tv = (textview)single_row.findviewbyid(r.id.textview1); tv.settext(text[position]); chkbox = (checkbox)single_row.findviewbyid(r.id.checkbox1); }else{ if(position<6){ layoutinflater inflater = (layoutinflater)context.getsystemservice(context.layout_inflater_service); single_row = inflater.inflate(r.layout.layout_phone, null, true); textview tv = (textview)single_row.findviewbyid(r.id.textview1); tv.settext(text[position]); } } if(position==6){ layoutinflater inflater = (layoutinflater)context.getsystemservice(context.layout_inflater_service); single_row = inflater.inflate(r.layout.layout_mail, null, true); textview tv = (textview)single_row.findviewbyid(r.id.textview1); tv.settext(text[position]); } return single_row; } }
and use customlistadapter inside activity:
mlist = (listview)findviewbyid(r.id.listview1); customlistadapter adapter = new customlistadapter(this, texts); mlist.setadapter(adapter);
now ids of input widget of different layout, there way ?
thank you
Comments
Post a Comment