So I have 3 layouts as follows:
first.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/reward_icon"
android:layout_marginLeft="15dp"
android:layout_height="55dp"
android:layout_width="55dp"
android:src="@drawable/gift"/>
<TextView
android:id="@+id/outlet_name"
android:layout_toRightOf="@id/reward_icon"
android:layout_marginRight="45dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft = "15dip"
android:hint="outlet"
/>
<TextView
android:id="@+id/distance"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="0.0km"/>
<TextView
android:id="@+id/reward"
android:layout_toRightOf="@id/reward_icon"
android:layout_toLeftOf="@id/distance"
android:layout_below="@id/outlet_name"
android:layout_marginRight="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft = "15dip"
android:hint="Reward"
/>
<TextView
android:id="@+id/locality"
android:layout_toRightOf="@id/reward_icon"
android:layout_toLeftOf="@id/distance"
android:layout_below="@id/reward"
android:layout_marginRight="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft = "15dip"
android:hint="Locality"
/>
</RelativeLayout>
second.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logo"
android:layout_marginLeft="15dp"
android:layout_height="55dp"
android:layout_width="55dp"
android:src="@drawable/fav_icon"/>
<TextView
android:id="@+id/outlet_name"
android:layout_toRightOf="@id/logo"
android:layout_marginRight="45dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft = "15dip"
android:hint="outlet"
/>
<TextView
android:id="@+id/distance"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="0.0km"/>
<TextView
android:id="@+id/reward"
android:layout_toRightOf="@id/logo"
android:layout_toLeftOf="@id/distance"
android:layout_below="@id/outlet_name"
android:layout_marginRight="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft = "15dip"
android:hint="Reward"
/>
<TextView
android:id="@+id/locality"
android:layout_toRightOf="@id/logo"
android:layout_toLeftOf="@id/distance"
android:layout_below="@id/reward"
android:layout_marginRight="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft = "15dip"
android:hint="Locality"
/>
</RelativeLayout>
third.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/fav_icon"
android:layout_marginLeft="15dp"
android:layout_height="55dp"
android:layout_width="55dp"
android:src="@drawable/heart"/>
<TextView
android:id="@+id/outlet_name"
android:layout_toRightOf="@id/fav_icon"
android:layout_marginRight="45dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft = "15dip"
android:hint="outlet"
/>
<TextView
android:id="@+id/distance"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="0.0km"/>
<TextView
android:id="@+id/reward"
android:layout_toRightOf="@id/fav_icon"
android:layout_toLeftOf="@id/distance"
android:layout_below="@id/outlet_name"
android:layout_marginRight="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft = "15dip"
android:hint="Reward"
/>
<TextView
android:id="@+id/locality"
android:layout_toRightOf="@id/fav_icon"
android:layout_toLeftOf="@id/distance"
android:layout_below="@id/reward"
android:layout_marginRight="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft = "15dip"
android:hint="Locality"
/>
</RelativeLayout>
Now I made a layout all.xml as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include layout="@layout/first" />
<include layout="@layout/second" />
<include layout="@layout/third" />
</LinearLayout>
My problem is when I use all.xml it is showing reward_icon for all the data whether it should show reward_icon for first set of data, logo for second type of data and fav_icon for third type of data. I am using adaptor as follows:
String[] values = {"outlet_name","reward","locality","distance"};
int[] ids = {R.id.outlet_name,R.id.reward,R.id.locality,R.id.distance};
adapter = new SimpleAdapter(getActivity(), oslist,
R.all, values,ids);
list.setAdapter(adapter);
((SimpleAdapter) adapter).notifyDataSetChanged();
How can I solve this issue?
No comments:
Post a Comment