ListView getChildCount() return 1 when rotate

102 Views Asked by At

I have used about 4 hours to solve problem, but i can't. I want my ListView item do something in onConfigurationChanged. I first do follow thing.

android:configChanges="keyboardHidden|orientation|screenSize"

and my Activity implementation onConfigurationChanged, my Fragment also do it. Finally i implement onConfigurationChanged in my ListView item.All Activity and Fragment will invoke onConfigurationChanged when screen from portrait to landscape, but it won't invoke in ListView item. I custom a ListView and implement dispatchConfigurationChanged, and i find getChildCount will return 1 in dispatchConfigurationChanged. Because my ListView item is 2 and 3, so onConfigurationChanged won't invoke. But how can i solve it? I have search a long time , but i can't solve.enter image description here

1

There are 1 best solutions below

9
On

Maybe ask the Adapter attached to the ListView, he knows better ;)

The ListView has only one child, a LinearLayout, that's why.