请教一个分页加载数据的问题

模拟器可以加载更多数据,手机不行.就是用RecyclerView上拉加载更多数据,手机和模拟器都正常联网,加载更多是获取列表初始数据然后在Hanlder设置Adpater之后触发的,模拟器可以正常触发加载更多,真机不行.Hanlder里面我是这样写的:

               case SHOW_SEARCH_SUCCESS://手动搜索成功
                    mLoading.setVisibility(View.GONE);
                    mNoSearchStatus.setVisibility(View.GONE);
                    mSearching.setVisibility(View.VISIBLE);
                    mNoSearchResult.setVisibility(View.GONE);
                    mHavaResult.setVisibility(View.VISIBLE);

                    //搜索结果的RadioButton
                    ColorStateList csl = getResources().getColorStateList(R.color.button_text);//动态加载的RadioButton必须这样设置文字选中和普通颜色
                    //顶部按钮
                    for (int i = 0; i < resultTitles.length; i++) {
                        RadioButton tempButton = new RadioButton(SearchActivity.this);
                        tempButton.setTextColor(csl);//动态加载的RadioButton必须这样设置文字选中和普通颜色
                        tempButton.setButtonDrawable(null);           // 设置按钮的样式
                        tempButton.setText(resultTitles[i]);
                        tempButton.setId(i);
                        tempButton.setTextSize(15);
                        tempButton.setButtonDrawable(R.drawable.channel_button_shape);
                        tempButton.setPadding(30, 0, 30, 0);
                        tempButton.setBackgroundResource(R.drawable.channel_title_selector);
                        tempButton.setGravity(Gravity.CENTER);
                        RadioGroup.LayoutParams lp = new RadioGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                                ViewGroup.LayoutParams.WRAP_CONTENT);
                        lp.setMargins(15, 0, 15, 0);//设置RadioButton的边距
//                        mRadioGroup.addView(tempButton, lp);//TODO:临时不显示顶部按钮
                        if (i == 0) {
                            mRadioGroup.check(tempButton.getId());
                        }
                    }
                    //加载页面数据
                    mPageDatas = new ArrayList<>();
                    for (int i = 0; i < resultTitles.length; i++) {
                        mPageDatas.add(new SearchResultController(SearchActivity.this));//顶部有多少个RadioButton,ViewPager页面就添加多少个
                    }
                    //首次进来默认获取第一个RadioButton的数据
//                    getListData(0);
                    mViewPager.setAdapter(mPagerAdapter);
                    mRadioGroup.setOnCheckedChangeListener(SearchActivity.this);
                    mViewPager.addOnPageChangeListener(SearchActivity.this);
                    mPagerAdapter.notifyDataSetChanged();

                    TabController tabController = mPageDatas.get(0);
                    View rootView = tabController.getRootView();
                    RecyclerView recyclerView = rootView.findViewById(R.id.rv_have_result);
                    //创建布局管理
                    LinearLayoutManager layoutManager = new LinearLayoutManager(SearchActivity.this);
                    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                    recyclerView.setLayoutManager(layoutManager);
                    searchHaveResultAdapter = new SearchResultAdapter(R.layout.item_search_have_result, mHavaResultDatas, SearchActivity.this);
                    recyclerView.setAdapter(searchHaveResultAdapter);

                    searchHaveResultAdapter.setOnLoadMoreListener(SearchActivity.this);//加载更多数据
                    break;
阅读 1.2k
1 个回答

已自行解决问题

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题