how to pass arraylist of objects to populate each section heading text and its content?

烈酒焚心 提交于 2019-12-12 14:43:12

问题


I'am using StickyGridHeaders for GridView with sections.

this library is using R.array.countries to populate GridView with provided data and extracting first letter from passed string array to create section heading.

I m trying to pass an ArrayList of objects that will contain ArrayList for sections text named as "sectionArrayList" and "contentArrayListPrivate" and "contentArrayListPublic".

Now i want to play a for loop that will play till < sectionArrayList.size and will check is there any sections then show section text and then show all contents associated with this section by contentArrayListPrivate.size and similar for others but unable to achieve my target.

Can someone please point me towards right direction how to achieve this task ?

want to achive something like:


回答1:


I downloaded it and checked to solve your problem. so here is solution.

First of all that project is replaced to SuperSlim it is showing on your given link itself, so get superslim.

Then follow the example in that project to achieve it. In that example there is a file named CountryNamesAdapter.java open it, in the 37th line there i found this

final String[] countryNames = context.getResources().getStringArray(R.array.country_names);

which means the data is loaded from Array resource

replace it with

your data - convert your arraylist to string array and assign it like this

final String[] countryNames = myData.


来源:https://stackoverflow.com/questions/32181995/how-to-pass-arraylist-of-objects-to-populate-each-section-heading-text-and-its-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!