title: How to add fixed buttons above a ListView android?
body: <p>I want to have two buttons top of a listview. If I scroll below the listview I want that the buttons stay at top. I searched through many solutions on stackoverflow however I could not find the exact one for my case.</p>
  
  <p>My layout xml(mainlayout.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="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
      &lt;LinearLayout
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal"&gt;
          &lt;Button
              android:id="@+id/button1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="@string/latest_news_button" /&gt;
  
  
          &lt;Button
              android:id="@+id/button2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:text="@string/tracked_news_button" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;ListView
          android:id="@+id/mylist"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
  
      &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The graphical layout produced is just what I wanted:</p>
  
  <p><img src="https://i.stack.imgur.com/u2ecv.jpg" alt="graphical layout:"></p>
  
  <p>Here is my code to use this layout, in case I might fail to bind the Java code to layout;</p>
  
  <pre><code>public class MainActivity extends ListActivity{
  
  Button latestButton;
  Button trackedButton;
  ListView lv = null;
  
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.mainlayout);
  
      latestButton = (Button)findViewById(R.id.button1);
      latestButton.setOnClickListener(new OnClickListener() {         
          @Override
          public void onClick(View v) {
              Toast.makeText(MainActivity.this, "Latest Button!", Toast.LENGTH_LONG).show();
          }
      });
  
      trackedButton = (Button)findViewById(R.id.button2);
      trackedButton.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              Toast.makeText(MainActivity.this, "Tracked Button!", Toast.LENGTH_LONG).show();
          }
      });
  
      this.lv = getListView();
      String[] values = new String[]{"asdfa","qwerqwer","banbn"};
      lv.setAdapter(new ArrayAdapter&lt;String&gt;(BilTrackerMainActivity.this, android.R.layout.simple_expandable_list_item_1, values));
  
  }
  </code></pre>
  
  <p>however when this activity is called from my other activity my app unfortunately closed. LogCat says: </p>
  
  <blockquote>
    <p>Your content must have a ListView whose id attribute is 'android.R.id.list'</p>
  </blockquote>
  
  <p>But I try adding <code>lv = (ListView)findViewById(R.id.mylist);</code> instead of <code>this.lv = getListView();</code>. I could not solve this issue. 
  I am aware of <code>ListView#addHeaderView</code> but I want to solve my particular problem with using this kind of layout.</p>