title: Set ListView Height Programmatically
body: <p>I have a <code>TextView</code> and <code>ListView</code> in my activity.<code>ListView</code> intially set to <code>Visibility = gone</code> I need a functionality like if user click on <code>TextView</code>, <code>ListView</code> binds and will show to `Wrap_Content'. I have write the code so far </p>
  
  <p><strong>My XMl File</strong></p>
  
  <pre><code>&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;TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/txtDate"
      android:textSize="50dp"
      android:background="@color/colorSplash"
      android:text="20-11-2016"/&gt;
  
  &lt;ListView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/lstDesc"
      android:visibility="gone" /&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Java Code</strong></p>
  
  <pre><code> private void BindBookedList(){
    final ArrayList&lt;String&gt; arr = new ArrayList&lt;&gt;();
      arr.add("21-11-2016");
      arr.add("22-11-2016");
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_collapse, arr){
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
             View v = convertView;
              if (v == null) {
                  LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  v = vi.inflate(R.layout.list_collapse, null);
              }
              final TextView txtDate = (TextView) v.findViewById(R.id.txtDate);
              final ListView lstDesc = (ListView) v.findViewById(R.id.lstDesc);
              String strItemDAta = arr.get(position);
              txtDate.setText(strItemDAta);
              String[] arrContries =  getResources().getStringArray(R.array.ListOfAirport);
              ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;
                      (getApplicationContext(), R.layout.spinner_item, arrContries);
              lstDesc.setAdapter(adapter);
              txtDate.setOnClickListener(new View.OnClickListener(){
                  @Override
                  public void onClick(View view) {
  
                      com.kommlabs.pikmybox.MyUtlilites.ViewAnimationUtils.expand(lstDesc);
                  }
              });
              return v;
          }
      };
      ListView listBooked = ((ListView) findViewById(R.id.lstBookedPackages));
      listBooked.setAdapter(adapter);
  }
  </code></pre>
  
  <p><strong>ViewAnimationUtils class</strong></p>
  
  <pre><code>public class ViewAnimationUtils {
  static View view;
  public static void expand(View v) {
      view = v;
      v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      final int targtetHeight = v.getMeasuredHeight();
      v.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
      v.setVisibility(View.VISIBLE);
  
  }
  </code></pre>
  
  <p>In this code, i am calling <code>Expand</code> function of <code>ViewAnimationUtils</code> class. In expand function i have set layout height to <code>Wrap_Content</code> but Listview render height upto show only one item. <code>Listview</code> has 8 items on bind. </p>
  
  <p>How to set height of <code>ListView</code> to show all items in list ?</p>