简体   繁体   English

如何在一个活动中处理两个列表视图?

[英]How to Handle two listviews in one activity?

In my application,im using two listviews and both are not showing simultaneously.But im using the same "custom adapter class".But it is showing different results while implementing pagination.Pagination works well in the first listview which loads initially.But when i click another listview to show the results,it is not working 在我的应用程序中,im使用两个列表视图,并且两者未同时显示。但是im使用相同的“自定义适配器类”。但是在实现分页时显示不同的结果。分页在最初加载的第一个列表视图中工作良好。单击另一个列表视图以显示结果,它不起作用

My Problem: How to implement pagination in both of these listviews effectively?Is it better to use two different custom adapter class? 我的问题:如何在这两个列表视图中有效地实现分页?使用两个不同的自定义适配器类更好吗?

Here the sample code which i done for pagination------ 这是我为分页所做的示例代码

            btnNext.setVisibility(View.VISIBLE);
            TotalPages = TotalPages + 1;
            if (pagenum == 0) {

                            btnPrev.setVisibility(View.INVISIBLE);
                pagenum = pagenum + 1;
                }
                else {

    recentCracks = web.getAllRecentCrackUps(pagenum);
            if (recentCracks != null) {
    adapter = new DynamicListAdapter(KidsCrackMeUp.this, recentCracks);
        lstRecentPosts.setAdapter(adapter);
                    }
                        txtPageCount.setText(String.valueOf(pagenum));
                        txtTotalPages.setText(String.valueOf(totalpagecount));
                    }
        if (pagenum == 1) {
                            //btnPrev.setEnabled(false);
                            btnPrev.setVisibility(View.INVISIBLE);
                        }
                    }
                });

//Button Previous Ends Here----------- //此处的按钮上一个结尾-----------

    btnNext.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
        pagenum = pagenum + 1;
                        btnPrev.setVisibility(View.VISIBLE);
        TotalPages = TotalPages - 1;
            //btnPrev.setEnabled(true);
                if (TotalPages == 0) {
                btnNext.setEnabled(false);
                pagenum = pagenum - 1;
                }
                else 
                {
                recentCracks = web.getAllRecentCrackUps(pagenum);
                if (recentCracks != null)
                  {
            adapter = new DynamicListAdapter(KidsCrackMeUp.this, recentCracks);
            lstRecentPosts.setAdapter(adapter);
                     }
                        txtPageCount.setText(String.valueOf(pagenum));
                        txtTotalPages.setText(String.valueOf(totalpagecount));
                    }
                if (TotalPages == 1) {
        **strong text**//   btnNext.setEnabled(false);
                            btnNext.setVisibility(View.INVISIBLE);
                        }

                    }
                });

//Button Next Ends Here---- //按钮的下一个结束----

            }

            else

            {
                btnNext.setVisibility(View.GONE);
            }
            // rel.setVisibility(View.VISIBLE);

            lstRecentPosts.setAdapter(adapter);

Please elaborate your question.I didnt get anything from it. 请详细说明您的问题。我什么都没收到。 if you are trying to display two separate lists of same type then i would suggest you to go with SeparatedListAdapter 如果您要显示两个相同类型的单独列表,那么我建议您使用SeparatedListAdapter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM