如何在向下滚动列表视图时隐藏选项卡,然后在用户向上滚动时再次显示它们?

时间:2012-11-01 15:13:40

标签: android

如果用户向下滚动列表视图,我想让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;
            }
        });

1 个答案:

答案 0 :(得分:1)

Lars Werkman已经实施了一个Android库来实现Roman Nurik和Nick Butcher的UI原则。

https://github.com/LarsWerkman/QuickReturnListView