如果用户向下滚动列表视图,我想让tabhost的标签淡出
我有以下代码,但它不起作用
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;
}
});
答案 0 :(得分:1)
Lars Werkman已经实施了一个Android库来实现Roman Nurik和Nick Butcher的UI原则。