java.lang.NullPointerException when try listview.getChildAt()

前端 未结 3 1371
猫巷女王i
猫巷女王i 2021-01-25 07:12

There is ListView with correct values:

public class FragmentTab1 extends SherlockFragment {

ListView list;
LazyAdapter adapter;

@Override
public void onViewCre         


        
3条回答
  •  时光取名叫无心
    2021-01-25 08:17

    I'd think you'd get an indexoutofbounds but since it's null, this might be why: ListView getChildAt returning null for visible children

    Also, put a log statement in your for loop to display the value of all variables concerned, so: i and itemCount etc.

    And set a breakpoint just before the loop and run debug mode to step over to check the values as it loops through and you'll see what i value caused the nullpointer in the debugger or if you miss it, it will be in logcat

提交回复
热议问题