Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, as far as I got your needs I think you may just use the <code>ListView.addFooterView(View v)</code> method:</p> <p><a href="http://developer.android.com/reference/android/widget/ListView.html#addFooterView%28android.view.View%29" rel="nofollow noreferrer">http://developer.android.com/reference/android/widget/ListView.html#addFooterView(android.view.View)</a></p> <p>It will allow you to have all your list items + "a few buttons" footer to be scrolled as a single block.</p> <p>So the code should be smth like that:</p> <pre><code>import android.os.Bundle; import android.view.LayoutInflater; import android.widget.ArrayAdapter; import android.widget.LinearLayout; public class YourActivity extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LayoutInflater factory = getLayoutInflater(); LinearLayout footer = (LinearLayout) factory.inflate(R.layout.your_a_few_buttons_footer, null); getListView().addFooterView(footer); String[] array = new String[50]; for (int i = 0; i &lt; 50;) { array[i] = "LoremIpsum " + (++i); } setListAdapter( new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, array) ); } } </code></pre> <p>Note, the doc says <code>addFooterView()</code> should be called BEFORE the <code>setListAdapter()</code>.</p> <p><strong>UPDATE</strong>: to add a <code>View</code> at the top of the list use <code>ListView.addHeaderView(View v)</code>. Note that, for instance, <code>LinearLayout</code> is also a <code>View</code>. So you can put anything you want as a header or a footer and it'll be scrolled with the list as an indivisible block.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload