Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为何loadmore出不来? #9

Open
Lile1 opened this issue May 10, 2016 · 16 comments
Open

为何loadmore出不来? #9

Lile1 opened this issue May 10, 2016 · 16 comments

Comments

@Lile1
Copy link

Lile1 commented May 10, 2016

No description provided.

@HomHomLin
Copy link
Owner

能提供点详细的描述吗?

@Lile1
Copy link
Author

Lile1 commented May 10, 2016

list_order.setLoadMoreFooter(loadMoreView);
list_order.setLoadMoreCount(1000);
list_order.setAdapter(adapter);
list_order.onFinishLoading(true, false);

实际数据只有10条,也正确显示出来了。但是Loadmore就是出不来,也不报错

@Lile1
Copy link
Author

Lile1 commented May 10, 2016

list_order.setLoadMoreCount(1000);
去掉也不行

@HomHomLin
Copy link
Owner

把setLoadMoreFooter去掉试试看呢?

@Lile1
Copy link
Author

Lile1 commented May 10, 2016

setLoadMoreFooter去掉了 还是不行,奇怪了~

@HomHomLin
Copy link
Owner

方便把代码给我看下吗?

@Lile1
Copy link
Author

Lile1 commented May 10, 2016

当然可以,怎么给你呢? 发你邮箱?

@HomHomLin
Copy link
Owner

你把代码贴在这里就好了

@Lile1
Copy link
Author

Lile1 commented May 10, 2016

@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_order);
x.view().inject(this);
application = (MyApplication) getApplication();
yhqAdapter = new MainOrderAdapter(this, yhqList);
ddfAdapter = new DaodianfuAdapter(this, ddfList);

    list_order.setSwipeEnable(true);//open swipe
    DemoLoadMoreView loadMoreView = new DemoLoadMoreView(this, list_order.getRecyclerView());
    loadMoreView.setLoadmoreString("jiazaigengduo");
    loadMoreView.setLoadMorePadding(100);
    //list_order.setLoadMoreCount(1000);
    list_order.setLayoutManager(new LinearLayoutManager(this));
    list_order.setPagingableListener(new PullToRefreshRecyclerView.PagingableListener() {
        @Override
        public void onLoadMoreItems() {
            mHandler.sendEmptyMessageDelayed(MSG_CODE_LOADMORE, TIME);
        }
    });
    list_order.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mHandler.sendEmptyMessageDelayed(MSG_CODE_REFRESH, TIME);
        }
    });

    list_order.setLoadMoreFooter(loadMoreView);

    adapter = new OrderRecyclerViewAdapter(this, orderList, OrderActivity.this);
    list_order.setAdapter(adapter);
    list_order.onFinishLoading(true, false);


    MyApplication.showProgressDialog(OrderActivity.this, "提示", "正在加载...");
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            GetOrderList("all");
        }
    });
    thread.start();
}

@OverRide
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//Log.e("resultCode",resultCode+"");
if (requestCode == 200) {
switch (resultCode) {
case Activity.RESULT_OK:
btn_quanbu_click();
break;
default:
break;
}
}
}

private void GetOrderList(String type) {
    curOrderType=type;
    RequestParams params = new RequestParams(MyApplication.api_orderlist);
    params.addQueryStringParameter("type", type);
    Callback.Cancelable cancelled = x.http().post(params, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
            Gson gson = new Gson();
            try {
                MyApplication.showLog(result);
                JSONObject obj = new JSONObject(result);
                JSONArray arr = obj.getJSONObject("Variables").getJSONArray("orderlist");
                JSONObject oneOrder;
                for (int i = 0; i < arr.length(); i++) {
                    oneOrder = arr.getJSONObject(i);
                    model = gson.fromJson(oneOrder.toString(), OrderModel.class);
                    model.setPrice(oneOrder.getJSONObject("detail").getString("price"));
                    model.setNum(oneOrder.getJSONObject("detail").getString("num"));
                    model.setType(oneOrder.getJSONObject("detail").getString("type"));
                    model.setPic(oneOrder.getJSONObject("detail").getString("pic"));
                    model.setTitle(oneOrder.getJSONObject("detail").getJSONObject("title").getString("title"));
                    orderList.add(model);
                }

                if (orderList.size() == 0) {
                    list_order.setVisibility(View.GONE);
                    lin_girl.setVisibility(View.VISIBLE);
                } else {
                    list_order.setVisibility(View.VISIBLE);
                    lin_girl.setVisibility(View.GONE);
                }

                arr = obj.getJSONObject("Variables").getJSONArray("express");
                String[] str_express = new String[arr.length()];
                for (int i = 0; i < arr.length(); i++) {
                    str_express[i] = arr.getJSONObject(i).getString("cw");
                }
                application.setExpress(str_express);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            adapter.setCount(orderList.size());
            adapter.notifyDataSetChanged();
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
            Toast.makeText(x.app(), ex.getMessage(), Toast.LENGTH_LONG).show();
        }

        @Override
        public void onCancelled(CancelledException cex) {
            Toast.makeText(x.app(), "cancelled", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onFinished() {
            MyApplication.hideProgressDialog();
        }
    });
}

代码有点多,我就贴了2段和这个有关系的

@HomHomLin
Copy link
Owner

你把

mPtrrv.setPagingableListener(new PullToRefreshRecyclerView.PagingableListener() {
@OverRide
public void onLoadMoreItems() {
mHandler.sendEmptyMessageDelayed(MSG_CODE_LOADMORE, TIME);
}
});

注释掉看下LoadMoreView会不会出来

@Lile1
Copy link
Author

Lile1 commented May 10, 2016

还是不行,能否将整个项目打包发给您看看,可以吗?

@HomHomLin
Copy link
Owner

发我邮箱,我有时间帮你看下

@pengzhiming
Copy link

我也遇到了这个问题,请问怎么解决?

@tz-xbestdog
Copy link

以下是我遇到的情况:初始数据貌似要10条,才能加载更多。。。9条数据就不行

@tz-xbestdog
Copy link

image
,源码上默认最少10条。。。

@bovink
Copy link

bovink commented Jul 21, 2016

可以调用接口setLoadMoreCount方法自定义加载更多数据的限制

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants