1

I am working on an Android app. In my activity, I have a View A and a ListView B. I'm wondering if there is a way when I scroll the ListView B, the View A can move together (in the same direction, same speed, same distance)?

Thank you

Allan Jiang
  • 11,063
  • 27
  • 104
  • 165
  • take look on this thread http://stackoverflow.com/questions/3606530/listview-scroll-to-the-end-of-the-list-after-updating-the-list – mohammed momn Feb 11 '14 at 20:10

1 Answers1

0

I'm wondering if there is a way when I scroll the ListView B, the View A can move together (in the same direction, same speed, same distance)?

Yes You can achieve that by adding header to your listview.

You can also achieve the footer same way.

For Example:

public class MyList extends ListActivity {


/** Called when the activity is first created. */

  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    // create an array of Strings, that will be put to our ListActivity
    String[] names = new String[] { "Linux", "Windows7", "Eclipse", "Suse",
        "Ubuntu", "Solaris", "Android", "iPhone", "Linux", "Windows7",
        "Eclipse", "Suse", "Ubuntu", "Solaris", "Android", "iPhone" };
    View header = getLayoutInflater().inflate(R.layout.header, null);
    View footer = getLayoutInflater().inflate(R.layout.footer, null);
    ListView listView = getListView();
    listView.addHeaderView(header);
    listView.addFooterView(footer);
    setListAdapter(new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_single_choice,
        android.R.id.text1, names));

  }
} 
Sagar Shah
  • 4,272
  • 2
  • 25
  • 36