GridView implementation in Android Click to see more function examples

First, let's take a look at the renderings;

Let's talk about my requirements first: view group members. If there are more than 15 people, all will be displayed. If there are more than 15 people, 15 people will be loaded first, and the rest will not be displayed. Click View more to load all. Let's talk about the logic I implemented: first, judge the number of group members. If it is less than or equal to 15, use GridView to load all data and hide the buttons to view more. If there are more than 15 people, the load more button will be displayed. First load 15 pieces of data, and the rest will not be loaded. After clicking the button, get all the data and put it into your written adapter, then load and refresh, and then hide the load more button.

OK, let's look at the code:

Then there is the core code of some judgments in activity:

First, judge and load for the first time

Code after clicking the button:

Then paste my adapter code:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>