android-cube-app icon indicating copy to clipboard operation
android-cube-app copied to clipboard

底部加载不生效

Open yongchao1210 opened this issue 8 years ago • 3 comments

======= XML==============

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">

<in.srain.cube.views.ptr.PtrClassicFrameLayout xmlns:cube_ptr="http://schemas.android.com/apk/res-auto"
    android:id="@+id/rotate_header_list_view_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f1f1f1"
    cube_ptr:ptr_duration_to_close="200"
    cube_ptr:ptr_duration_to_close_header="1000"
    cube_ptr:ptr_keep_header_when_refresh="true"
    cube_ptr:ptr_pull_to_fresh="false"
    cube_ptr:ptr_ratio_of_header_height_to_refresh="1.2"
    cube_ptr:ptr_resistance="1.7">

    <in.srain.cube.views.loadmore.LoadMoreListViewContainer
        android:id="@+id/load_more_list_view_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/cube_mints_white">

        <ListView
            android:id="@+id/rotate_header_list_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:choiceMode="singleChoice"
            android:divider="@null"
            android:fadingEdge="none"
            android:listSelector="@android:color/transparent"
            android:paddingLeft="12dp"
            android:paddingRight="12dp"
            android:scrollbarStyle="outsideOverlay" />
    </in.srain.cube.views.loadmore.LoadMoreListViewContainer>

</in.srain.cube.views.ptr.PtrClassicFrameLayout>

===============JAVA=====================

 private void initUPTRefreshListView() {
    //1.初始化listview
    mListView = (ListView) findViewById(R.id.rotate_header_list_view);

// View view = LayoutInflater.from(this).inflate(R.layout.footer_loading_view, null); // 为listview的创建一个footerview, // mListView.addFooterView(view, null, false); // 为listview的创建一个headerview,注意,如果不加会影响到加载的footview的显示! View headerMarginView = new View(this); headerMarginView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LocalDisplay.dp2px(20))); mListView.addHeaderView(headerMarginView);

    //2.绑定模拟的数据
    mListView.setAdapter(mQuickAdapter = new QuickAdapter<Map<String, String>>(this, R.layout.activity_baseadapter_item, mapList) {
        @Override
        protected void convert(BaseAdapterHelper helper, Map<String, String> item) {
            helper.setText(R.id.name, item.get("name"));
        }
    });

    //3.设置下拉刷新组件和事件监听
    mPtrFrame = (PtrClassicFrameLayout) findViewById(R.id.rotate_header_list_view_frame);
    mPtrFrame.setLoadingMinTime(1000);
    mPtrFrame.setPtrHandler(new PtrHandler() { // 顶部拉动监听
        @Override
        public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return PtrDefaultHandler.checkContentCanBePulledDown(frame, mListView, header);
        }

        @Override
        public void onRefreshBegin(PtrFrameLayout frame) {
            // 请求网络
            new GetDataTask().execute();
        }
    });
    mPtrFrame.postDelayed(new Runnable() { //设置下拉延时自动刷新数据
        @Override
        public void run() {
            loadingInfo();
        }
    }, 150);

    //4.加载更多的组件
    LoadMoreListViewContainer  mLoadMoreListViewContainer = (LoadMoreListViewContainer) findViewById(R.id.load_more_list_view_container);
    mLoadMoreListViewContainer.setAutoLoadMore(true);//设置是否自动加载更多
    mLoadMoreListViewContainer.useDefaultHeader();
    mLoadMoreListViewContainer.setLoadMoreHandler(new LoadMoreHandler() {
        @Override
        public void onLoadMore(LoadMoreContainer loadMoreContainer) {
            // 请求下一页数据

// new GetDataTask().execute(); Toast.makeText(getApplication(), "底部加载更多数据--开始", Toast.LENGTH_SHORT).show(); } }); }

问题:底部没有试图,而且 onLoadMore 方法没有调用成功 。。。(底部加载更多不生效)。请帮忙看看哪里问题

yongchao1210 avatar Sep 28 '16 08:09 yongchao1210

帮顶

gao117348222 avatar Sep 28 '16 09:09 gao117348222

不好意思,已经搞定了,是我自己的问题,我没有调用 mLoadMoreListViewContainer.loadMoreFinish(false, true); 所以无法显示,看了源码才明白。。。

不过建议作者 ,在滑到底部的时候,底部视图默认显示出来,不是手松开之后才显示,这样视觉更好点

yongchao1210 avatar Sep 29 '16 09:09 yongchao1210

在滑到底部的时候,底部视图默认显示出来,不是手松开之后才显示,但是数据加载还是放在手松开后再加载,这样视觉更好点

yongchao1210 avatar Sep 29 '16 09:09 yongchao1210