title: Creating listview in fragment android
body: <p>First of all, Thank you for answering. I am a newbie in android app development .I have made a fragment called fragment_list for creating a listview dynamically.The problem is that when the application runs the screen remains blank.I have tried to make a listview that has an image and a TextView. I am yet to implement setOnItemClickListener(). I have used Fragment Transaction in the Main_Activity.java to add the Fragment.Here are the files.</p>
  
  <p>main_layout.xml:</p>
  
  <pre><code>&lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
  
      android:id="@+id/groups"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Main_Activity.java</p>
  
  <pre><code>package com.cloudplay.spotvideo;
  
  import android.app.Activity;
  import android.app.FragmentManager;
  import android.app.FragmentTransaction;
  import android.os.Bundle;
  
  public class Main_Activity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main_layout);
      Fragment_List f1 = new Fragment_List();
      FragmentManager manager = getFragmentManager();
  
      FragmentTransaction transaction = manager.beginTransaction();
      transaction.add(R.id.groups, f1, "MAIN_LIST");
      transaction.addToBackStack("MAIN-LIST");
      transaction.commit();
  
  }
  
  }
  </code></pre>
  
  <p>fragment_list.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ListView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" 
  android:id="@android:id/list"&gt;
  
  
  &lt;/ListView&gt;
  </code></pre>
  
  <p>Fragment_List.java</p>
  
  <pre><code>package com.cloudplay.spotvideo;
  
  import android.os.Bundle;
  import android.app.ListFragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  
  public class Fragment_List extends ListFragment implements
      AdapterView.OnItemClickListener {
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      return inflater.inflate(R.layout.fragment_list, container, false);
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onActivityCreated(savedInstanceState);
  
      ArrayAdapter adapter = new ArrayAdapter(getActivity(),
              R.layout.single_row, R.array.MainList);
      setListAdapter(adapter);
      getListView().setOnItemClickListener(this);
  
  }
  
  @Override
  public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
      // TODO Auto-generated method stub
  
  }
  }
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.cloudplay.spotvideo"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  &lt;uses-sdk
      android:minSdkVersion="14"
      android:targetSdkVersion="18" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name="com.cloudplay.spotvideo.Main_Activity"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>single_row.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="horizontal" &gt;
  
  &lt;ImageView
      android:id="@+id/imageView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/ic_launcher" /&gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="match_parent"
      android:layout_height="52dp"
      android:text="" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Strings.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  
  &lt;string name="app_name"&gt;SpotVideo&lt;/string&gt;
  &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
  &lt;string name="hello_world"&gt;Hello world!&lt;/string&gt;
  
  &lt;string-array name="MainList"&gt;
      &lt;item name="movies"&gt;Movies&lt;/item&gt;
      &lt;item name="music"&gt;Music&lt;/item&gt;
  &lt;/string-array&gt;
  &lt;string-array name="Film"&gt;
      &lt;item name="hollywood"&gt;Hollywood&lt;/item&gt;
      &lt;item name="bollywood"&gt;Bollywood&lt;/item&gt;
      &lt;item name="tollywood"&gt;Tollywood&lt;/item&gt;
  &lt;/string-array&gt;
  
  &lt;/resources&gt;
  </code></pre>