Display icons in ListFragment
<p>I like to display icons at listview implemented using listfragment. I have MainActivity.java (with activity_main.xml) and MyListFragment.java(with my_list_fragment.xml). MainActivity loads MyListFragment. Then I'd like to display icon image at the list fragment. For icon image, I made list_row.xml. Now I can display listview, but I don't know where to inflate list_row.xml. Let me show the process step by step.
(1) MainActivity.java load listfragment in onCreate as follow</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);       
    // Create the initial list fragment
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    listFragment = new MyListFragment(this);;
    Fragment fragment = listFragment;   
    fragmentTransaction.add(R.id.tracker_container, fragment, "MYLIST");
    fragmentTransaction.commit();
}
</code></pre>

<p>(2)listfragment inflate my_list_fragment.xml in onCreateView as follow</p>

<pre><code> public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view =  inflater.inflate(R.layout.my_list_fragment, container, false); 
    setListAdapter(new ArrayAdapter&lt;String&gt;(getActivity(), 
            android.R.layout.simple_list_item_1,
        mListItems));
    return view;
}
</code></pre>

<p>So now listview is displayed with text from mListItems.
(3)Now where to inflate the list_row to display icons? xml files are shown as follow</p>

<pre><code>activity_main.xml

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"&gt;

&lt;LinearLayout android:id="@+id/tracker_container"
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="1"/&gt;

&lt;/LinearLayout&gt;

my_list_fragment.xml

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent"&gt;

&lt;ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:divider="#b5b5b5"
    android:dividerHeight="1dp"
    android:listSelector="@drawable/list_selector" &gt;
&lt;/ListView&gt;
</code></pre>

<p></p>

<p>list_row.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:background="@drawable/list_selector"
android:orientation="horizontal"
android:padding="5dip" &gt;

&lt;!--  ListRow Left sied Thumbnail image --&gt;
&lt;LinearLayout android:id="@+id/thumbnail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="3dip"
    android:layout_alignParentLeft="true"
    android:background="@drawable/image_bg"
    android:layout_marginRight="5dip"&gt; 
    &lt;ImageView 
        android:id="@+id/list_image"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:src="@drawable/vehicle" 
        android:contentDescription="@string/idimage"/&gt;       
&lt;/LinearLayout&gt;

&lt;!-- Rightend Arrow --&gt;
&lt;ImageView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/rightarrow"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true" 
    android:contentDescription="@string/arrow"/&gt;


&lt;/RelativeLayout&gt;
</code></pre>
