title: How to display the listview content in xml file in android
body: <p>I have 2 xml file </p>
  
  <ol>
  <li>MainActivity.xml
  2.Example.xml</li>
  </ol>
  
  <p>I have listview in Example.xml.the code I have written in Example.java. But the data is not displaying in listview..Kindly go through my code</p>
  
  <p><strong>Example.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/profileSwitcher"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
  
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;ListView
          android:id="@+id/listPasscode"
          android:layout_height="wrap_content"
          android:layout_width="match_parent"&gt;
      &lt;/ListView&gt;
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Test"/&gt;
  
  
  &lt;/LinearLayout&gt;
      &lt;/ViewSwitcher&gt;
  </code></pre>
  
  <p><strong>Example.java</strong></p>
  
  <pre><code>public class ListViewAndroidExample extends Activity {
      ListView listView ;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  
          listView = (ListView) findViewById(R.id.listPasscode);
  
          // Define a new Adapter
          // First parameter - Context
          // Second parameter - Layout for the row
          // Third parameter - ID of the TextView to which the data is written
          // Forth - the Array of data
  
          // Array of strings...
          String[] countryArray = {"India", "Pakistan", "USA", "UK"};
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
            android.R.layout.simple_list_item_1, android.R.id.text1, countryArray);
  
          // Assign adapter to ListView
          listView.setAdapter(adapter);
  
          setContentView(R.layout.activity_list_view_android_example);
  
      }
  
  }
  </code></pre>
  
  <p>Is linking between xml and java file right ?If not suggest me</p>