In ExpandableListview
I using multiple Group Header
with multiple Child view
The first Group Header
text "Shape" that has childview containing imageview
and checkbox
Initially I get 6 fresh shape names
in childview
when I scroll this ,the name repeats (not getting remaining 6 fresh names)
ExpandableListviewActivity.java
listDataChild.put(listDataHeader.get(0), shape_list);
Log.e("details", "karjeev112 "+shape_list);
@Override
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (error_flag==1) { // If no network
Toast.makeText(SearchActivity.this,"Network Error",Toast.LENGTH_SHORT).show();
}
else{
listAdapter=new ExpandableListAdapter(SearchActivity.this, listDataHeader, listDataChild);
expListView.setAdapter(listAdapter);
expListView.setItemChecked(0, true);
expListView.setSelected(true);
listAdapter.notifyDataSetChanged();
expListView.invalidateViews();
expListView.requestLayout();
}
if (progressDialog!=null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
ExpandableListAdapter.java
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
String childText = (String) getChild(groupPosition, childPosition);
Log.e("_childText", "karjeevch "+childText);
int itemType = getChildType(groupPosition,childPosition);
ViewHolder viewHolder = null;
switch (itemType) {
case 0:
viewHolder = null;
if (convertView==null) {
viewHolder=new ViewHolder();
convertView = infalInflater.inflate(R.layout.list_child_shape, null);
viewHolder.shape_name = (CheckBox) convertView.findViewById(R.id.shape_chk_box);
viewHolder.img_shape_icon=(ImageView)convertView.findViewById(R.id.img_shape);
imageLoader.DisplayImage("http://rosycontact.com/shashvat/images/"+childText.toLowerCase()+".png", viewHolder.img_shape_icon);
Log.e("shape", "karjeevshp "+childText);
viewHolder.shape_name.setText(childText);
convertView.setTag(viewHolder);
final CheckBox shape_name_temp=viewHolder.shape_name;
viewHolder.shape_name.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
int id=buttonView.getId();
if (id==R.id.shape_chk_box) {
if (shape_name_temp.isChecked()==true) {
String shape_str=shape_name_temp.getText().toString();
All_link.SHAPE_LIST.add(shape_str);
Toast.makeText(_context, shape_name_temp.getText().toString(), Toast.LENGTH_SHORT).show();
Log.e("chk_shape", "karjeevch "+shape_name_temp.getText().toString());
}
else{
String shape_str=shape_name_temp.getText().toString();
All_link.SHAPE_LIST.remove(shape_str);
}
}
}
});
}
else{
viewHolder=(ViewHolder)convertView.getTag();
}
return convertView;
}