After filter a listview,how can I obtain the position of the first listview?

好久不见. 提交于 2019-12-01 02:23:55
Marshal Chen

I slove it with three arrays. Only test code:

String positionString[]=new String[22];
                int latterPosition[]=new int[22];
                for (int i = 0; i < latterPosition.length; i++) {
                    positionString[i]="";
                    latterPosition[i]=0;
                }
                int latterCount=0;
                for (int i = 0; i < positions.length; i++) {
                    if (positions[i]==10) {
                        positionString[latterCount]=i+"";
                        latterPosition[latterCount]=10;
                        latterCount++;
                    }
                }

this happens becouse Android gives you only IDs for the itmes you currently see + maybe two hidden on button and two hidden on top.

In this tutorial you can see how to create a ListView with a model, this helps me, when i got this problem before. Add this to you code and change it (I think you don't need the checkboxes).

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