ListView in ScrollView potential workaround

Ok, as far as I got your needs I think you may just use the ListView.addFooterView(View v) method:

http://developer.android.com/reference/android/widget/ListView.html#addFooterView(android.view.View)

It will allow you to have all your list items + “a few buttons” footer to be scrolled as a single block.

So the code should be smth like that:

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 < 50;) { array[i] = "LoremIpsum " + (++i); }

        setListAdapter(
            new ArrayAdapter<String>(this, R.layout.list_item, array)
        );
    }   
}

Note, the doc says addFooterView() should be called BEFORE the setListAdapter().

UPDATE: to add a View at the top of the list use ListView.addHeaderView(View v). Note that, for instance, LinearLayout is also a View. 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.

Leave a Comment