Iterate through ListView and get EditText-Field values

后端 未结 4 1092
借酒劲吻你
借酒劲吻你 2020-12-03 04:37

I\'ve created a ListView (myList) with one EditText-Field in each row (R.id.mannschaften). Under the ListView, I\'ve created a Button and set an OnClickListener for it in th

4条回答
  •  囚心锁ツ
    2020-12-03 05:19

    Regarding why the selected answer might sometimes throw a null on the "et = (EditText) v.findViewById(i);"

    Would it not be at that point trying to select the item at position i WITHIN the view that you had previously selected? Thus if there are fewer items in the child views than there are items in the whole list, you would get null due to i trying to select items that don't exist.

    Perhaps a nested loop could solve this problem? Or if you already know the index of the element you need, simply give it the index directly.

提交回复
热议问题