怎样的android限制列表项显示ListView和一个按钮显示更多按钮、更多、列表、android

2023-09-07 16:03:52 作者:黑白颠倒的年华

我正在从数据库中的数据,并在ListView使用自定义列表显示适配器

I am getting data from Database and displaying using a custom list adapter in a ListView.

我需要显示只有10 ListView中的项目。和第10项的按钮显示的文字后,显示更多,当点击这个按钮,在列表视图中显示更多的10个项目从数据库中。

I need to display only 10 items in ListView. and after 10th item a button show with text "Show More", when click this button so show more 10 items from Database in listview.

我怎么能做到这一点?

请让我知道与code例如

Please let me know with code example

感谢

推荐答案

在底座适配器,最初取I = 10;然后使用BaseAdapter这个我,在getCount将()方法。

In Base Adapter, initially take i=10; then use this "i" in getCount() method of BaseAdapter.

public int getCount() {
// TODO Auto-generated method stub
return i;
}

而在你的显示更多按钮,单击递增的我,然后调用适配器。

And in your "show more" Button click Increment the i, then call adapter.

例如:

i=i+10;
adapter.notifyDataSetChanged();
 
精彩推荐
图片推荐