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
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
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));
}
}