隐藏Android-PullToRefresh以及Action Bar

时间:2014-06-04 19:32:47

标签: java android android-fragments android-actionbar pull-to-refresh

我有三个标签,并将操作栏隐藏在中间标签上。第三个标签已拉动刷新。 Android可以很好地动画进出Action Button的滑动,但当我在第三个选项卡上刷新并切换到中间选项卡(隐藏Action Bar的位置)时,我看到以下内容:

Pulling to refresh

Refreshing bar still overlaid when action bar hidden

操作栏对PageAdapter隐藏,隐藏如下:

@Override
public void onPageSelected(int position) {
    if (position == 1) {
        mActionBar.hide();
    } else {
        mActionBar.show();
    }
}

Pull to Refresh在片段(第三个标签)中实现,布局为:

<?xml version="1.0" encoding="utf-8"?>
<uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ptr_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey_canvas_bg"
android:orientation="vertical"
>

<se.emilsjolander.stickylistheaders.StickyListHeadersListView
    android:id="@+id/list_feed"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshLayout>

并在OnCreateView中初始化如下:

mPullToRefreshLayout = (PullToRefreshLayout) view.findViewById(R.id.ptr_layout);
    ActionBarPullToRefresh.from(getActivity())
    .allChildrenArePullable()
    .useViewDelegate(StickyListHeadersListView.class, new ViewDelegate() {
        @Override
        public boolean isReadyForPull(View view, float v, float v2) {
        View childView = updatesListView.getChildAt(0);
        int top = (childView == null) ? 0 : childView.getTop();
        return top >= 0;
        }
    })
    .listener(this)
    .setup(mPullToRefreshLayout);

感谢您的帮助!

0 个答案:

没有答案