**R.layout.my drawer_list_item.xml**
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="60dp" >
<ImageView
android:id="@+id/flag"
android:layout_width="40dp"
android:layout_height="40dp"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:contentDescription="@string/app_name" />
<TextView
android:id="@+id/country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/flag"
android:layout_centerVertical="true"
android:textSize="15sp" />
<TextView
android:id="@+id/count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center"
android:padding="0dp"
android:background="@color/DarkGray"
android:textSize="15sp" />
</RelativeLayout>
**java code**
private SimpleAdapter mAdapter;
private List<HashMap<String,String>> mList ;
final private String ITEM = "item";
final private String FLAG = "flag";
final private String COUNT = "count";
String[] mCountries =new String[]{"item 1","item 2","item3"} ;
int[] mFlags = new int[]{
R.drawable.abc_ic_clear,
R.drawable.abc_ic_clear,
R.drawable.abc_ic_clear,
};
String[] mCount = new String[]{
"1", "2", "3" };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mList = new ArrayList<HashMap<String,String>>();
for(int i=0;i<3;i++){
HashMap<String, String> hm = new HashMap<String,String>();
hm.put(ITEM, mCountries[i]);
hm.put(COUNT, mCount[i]);
hm.put(FLAG, Integer.toString(mFlags[i]));
mList.add(hm);
}
}
**set adapter for ListView**
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mDrawerListView = (ListView) inflater.inflate(
R.layout.fragment_navigation_drawer, container, false);
mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(position);
}
});
String[] from = { FLAG,ITEM,COUNT };
int[] to = { R.id.flag , R.id.country , R.id.count};
mAdapter = new SimpleAdapter(getActionBar().getThemedContext(), mList, R.layout.my drawer_list_item, from, to);
mDrawerListView.setAdapter(mAdapter);
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
return mDrawerListView;
}