Reputation: 21893
I want to make the tabs of a tabhost fade up if the user is scrolling down a listview
I have the following code but it does not work
ListView ls = (ListView) findViewById(R.id.list);
ls.setOnScrollListener(new OnScrollListener() {
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
int previousVisible = 3;
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (previousVisible < firstVisibleItem) {
getParent().findViewById(android.R.id.tabhost)
.setVisibility(View.INVISIBLE);
} else {
getParent().findViewById(android.R.id.tabhost)
.setVisibility(View.VISIBLE);
}
previousVisible = firstVisibleItem;
}
});
Upvotes: 1
Views: 5112
Reputation: 6182
Lars Werkman has implemented an Android Library to implement this UI principle from Roman Nurik and Nick Butcher.
https://github.com/LarsWerkman/QuickReturnListView
Upvotes: 1