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

后端 未结 2 1778
生来不讨喜
生来不讨喜 2021-01-07 15:57

After filter a listview,how can I obtain the position of the first listview? I use simpleadapter to fill the listview. Each item in the datasource has its own id,and I use

2条回答
  •  暖寄归人
    2021-01-07 16:24

    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++;
                        }
                    }
    

提交回复
热议问题