Sometimes listView.getChildAt(int index) returns NULL (Android)

后端 未结 4 1692
离开以前
离开以前 2020-12-02 02:06

I have a listView with a custom adapter. When something happens (a click in a child) I do some calculation things and modify the child View. IF some condition has been fulfi

4条回答
  •  忘掉有多难
    2020-12-02 02:58

    I test it with one line of code when I need to go within a valid position of a Listview. here is your variables used as an example. where lv_data is the ListView and tv is your TextView.

    if ( lv_data.getChildAt(lv_data.getPositionForView(tv)) != null) {
        int position = lv_data.getPositionForView(tv);
    }
    

提交回复
热议问题