I have listview in that i am inflating a Layout that will have checkbox like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<CheckBox
android:id="@+id/checkBox"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Now from the main Activity i am calling a Adapter class
public void setData(){
dataList = new ArrayList<String>();
Adapterclass = new MAdapter(this);
for (int i = 0; i < data.length; i++) {
Adapterclass .addItem(str[i]);
dataList .add(str[i]);
}
listview.setAdapter(Adapterclass);
}
Base Adapter Class
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
CheckBox cb;
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.main, parent, false);
cb = (CheckBox) convertView.findViewById(R.id.checkbox);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
String str = mData.get(position);
return convertView;
}
I want to set the value of the checkbox i.e cb
in the adapter class how can we do this .Please help me in this
Aucun commentaire:
Enregistrer un commentaire