getView
function is called many times hence the childview is being shown multiple times.I don't know why this is happening,the childrows are shown by 5 times as I have 5 textview in a row.here is my code getChildView()
and getChild()
of expandablelistview:
public View getChildView(int groupPosition,int childPosition, boolean isLastChild, View convertView,
ViewGroup parent) {
final List<String> childText = getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.childrow, null);
}
final TextView address = (TextView)convertView.findViewById(R.id.address);
final TextView timings = (TextView)convertView.findViewById(R.id.timings);
final TextView telephone = (TextView)convertView.findViewById(R.id.telephone);
final TextView citcoun = (TextView)convertView.findViewById(R.id.citcoun);
address.setText(childText.get(0));
timings.setText(childText.get(1));
telephone.setText(childText.get(2));
String citcounT = childText.get(3)+","+childText.get(4);
citcoun.setText(citcounT);
return convertView;
}
public List<String> getChild(int groupPosition, int childPosition) {
return childnames.get(parentNames.get(groupPosition));
}
And its the xml of expnadablelist
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ExpandableListView
android:id="@+id/storelist"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
</ExpandableListView>
</LinearLayout>
this is childrow.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:text="79-A HBFC,Faisla Town,Lahore" />
<TextView
android:id="@+id/citcoun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:layout_below="@+id/address"
android:layout_marginTop="10dp"
android:text="Lahore" />
<TextView
android:id="@+id/timings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/citcoun"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:text="Mon-Sat: 9 am-10 pm" />
<TextView
android:id="@+id/telephone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/timings"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:text="0346-4678570" />
Kindly help me if u know what's wrong with this