lixplor / android-Q-A

🐞 android related questions and answers
0 stars 0 forks source link

ListView, GridView在notifyDataSetChanged后, getChildCount总是0 #44

Closed lixplor closed 7 years ago

lixplor commented 7 years ago

ListView, GridView在notifyDataSetChanged后, getChildCount总是0

lixplor commented 7 years ago

原因: setAdapter()是异步的, 不会立刻设置进去 解决: 使用ListView或GridView的post(Runnable r);方法, 在该方法中调用getChildCount