title: Creating Listview programatically without xml : not showing any cell
body: <p>I'm trying to create listview programatically in android. </p>
  
  <p>My goal is to create a dynamic view where if i click one button it will change the content inside the layout from listview into another view or vice versa. </p>
  
  <p>Everything seems good i successfully put the listview inside a linear layout from the java file and i did that by creating a custom layout for the cell.</p>
  
  <p>The problem is it shows the listview but it does not add the cell. 
  I know that it place the listview because the background become green when  I run it but it does not show up the cell of the listview. </p>
  
  <p>Am i missing something? </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="match_parent"
      android:layout_height="match_parent"
      android:backgroundTint="@color/colorPrimary"&gt;
  
      &lt;TextView
          android:id="@+id/listContent"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="hello"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>MainActivity.java </p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
      LinearLayout mainView,sideView;
      ListView notelist;
      String[] Names = {"great","good","average","great","good","average"};
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          mainView = (LinearLayout)findViewById(R.id.mainView);
  
          notelist = new ListView(this);
          notelist.setBackgroundColor(Color.GREEN);
          CustomAdapter customAdapter = new CustomAdapter();
          notelist.setAdapter(customAdapter);
          notelist.setLayoutParams(new LinearLayout.LayoutParams(
                  LinearLayout.LayoutParams.MATCH_PARENT,
                  LinearLayout.LayoutParams.MATCH_PARENT));
  
          mainView.addView(notelist);
  
      }
  
      class CustomAdapter extends BaseAdapter{
  
          @Override
          public int getCount() {
              return Names.length;
          }
  
          @Override
          public Object getItem(int position) {
              return null;
          }
  
          @Override
          public long getItemId(int position) {
              return 0;
          }
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              View view = getLayoutInflater().inflate(R.layout.list_vertical,null);
  
              TextView contentText = (TextView) view.findViewById(R.id.listContent);
              contentText.setText(Names[position]);
  
              return null;
          }
      }
  
  }
  </code></pre>
  
  <p>main xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal"
      tools:context=".MainActivity"&gt;
  
  
  
      &lt;LinearLayout
          android:id="@+id/sideView"
          android:layout_weight=".20"
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
          &lt;ImageButton
              android:id="@+id/oneBtn"
              android:layout_width="@dimen/ButtonSize"
              android:layout_height="@dimen/ButtonSize"
              android:background="@android:color/transparent"
              android:src="@drawable/noct"
             /&gt;
          &lt;ImageButton
              android:id="@+id/twoBtn"
              android:layout_width="@dimen/ButtonSize"
              android:layout_height="@dimen/ButtonSize"
              android:background="@android:color/transparent"
              android:src="@drawable/note"
              /&gt;
          &lt;ImageButton
              android:id="@+id/threeBtn"
              android:layout_width="@dimen/ButtonSize"
              android:layout_height="@dimen/ButtonSize"
              android:background="@android:color/transparent"
              android:src="@drawable/journal"
              /&gt;
          &lt;ImageButton
              android:id="@+id/fourBtn"
              android:layout_width="@dimen/ButtonSize"
              android:layout_height="@dimen/ButtonSize"
              android:background="@android:color/transparent"
              android:src="@drawable/mic"/&gt;
          &lt;ImageButton
              android:id="@+id/fiveBtn"
              android:layout_width="@dimen/ButtonSize"
              android:layout_height="@dimen/ButtonSize"
              android:background="@android:color/transparent"
              android:src="@drawable/add"
              /&gt;
          &lt;ImageButton
              android:id="@+id/sixBtn"
              android:layout_width="@dimen/ButtonSize"
              android:layout_height="@dimen/ButtonSize"
              android:background="@android:color/transparent"
              android:src="@drawable/pencil"
              /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/mainView"
          android:layout_weight=".80"
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>