title: Create and add listview to layout at runtime
body: <p>I have design like this </p>
  
  <p>
  </p>
  
  <pre><code>&lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="0.20"
      android:orientation="horizontal" &gt;
  
      &lt;Button
          android:id="@+id/backbutton"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Back" /&gt;
  
      &lt;Button
          android:id="@+id/nextbutton"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="next" /&gt;
  &lt;/LinearLayout&gt;
  &lt;!-- the two columns part --&gt;
  
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_weight="0.80"
      android:orientation="horizontal" &gt;
  
      &lt;LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_weight="0.80" 
          android:id="@+id/submenue"
          &gt;
  
           &lt;!-- this will be the menue list --&gt;
           &lt;ListView
              android:id="@+id/MyHiddenListView"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:visibility="gone" 
              &gt;
  
  
  
              &lt;/ListView&gt;
  
              &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/contents"
              /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="First Name" /&gt;
  
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_weight="0.20" 
          android:id="@+id/mainLayout"
          &gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="second Name" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>I added the following code to the next button such that it display and fill the list </p>
  
  <pre><code>this.next = (Button)this.findViewById(R.id.nextbutton);
          this.next.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
  
                  String[] MainMenue =  new String[] { "aaaa", "bbb", "ccc"};
  
                  menueview = (ListView)findViewById(R.id.MyHiddenListView);
                  menueview.setVisibility(ListView.VISIBLE);
                  menueview.setAdapter(new submenueadapter(getApplicationContext(), MainMenue));
  
              }
          });
  </code></pre>
  
  <p>and the adaptor class is </p>
  
  <p>package com.appnetics;</p>
  
  <pre><code>import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.TextView;
  
  public class submenueadapter   extends ArrayAdapter&lt;String&gt; {
  
      private final Context context;
      private final String[] values;
  
  
      public submenueadapter(Context context,String[] objects)
      {
  
  
          super(context, R.layout.main, objects);
          this.context = context;
          this.values = objects;
      }
  
      public View getView(int position, View convertView, ViewGroup parent) {
          LayoutInflater inflater = (LayoutInflater) context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
          View rowView = inflater.inflate(R.layout.main, parent, false);
          TextView textView = (TextView) rowView.findViewById(R.id.contents);
  
          textView.setText(values[position]);
  
          // Change icon based on name
          String s = values[position];
  
          System.out.println(s);
  
  
          return rowView;
      }
  }
  </code></pre>
  
  <p>the problem is that the list be populated with the array plus the other controls in the page (the 2 buttons )</p>
  
  <p>the layout before clicking next
  <img src="https://i.stack.imgur.com/ZU1jn.png" alt="enter image description here">
  the layout after clicking 
  <img src="https://i.stack.imgur.com/QjOnt.png" alt="enter image description here">
  any idea to fix that please </p>
  
  <p>Best regards 
  Best regards</p>