怎样的android限制列表项显示ListView和一个按钮显示更多 [英] android How to limit list items display in ListView and a button show more

查看:242
本文介绍了怎样的android限制列表项显示ListView和一个按钮显示更多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从数据库中的数据,并在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();

这篇关于怎样的android限制列表项显示ListView和一个按钮显示更多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆