ViewGroup.getChildCount

前も使ったが、ViewGroup.getChildCountで、子Viewの数を取得できる。

ViewGroup  |  Android Developers

childView1, childView2の子Viewの数を取得し、表示する。

childView1, childView2をViewGroupにキャスト。(childView1, childView2はLinearLayoutなのでViewGroupにキャストできる。)
getChildCountで子Viewの数を取得。

f:id:BG1:20200302151739p:plain
2つ。

2つ。

f:id:BG1:20200302151804p:plain
2つ。

こちらも2つ。

TextView1つだとおもっていたが。
何故だろう。

Sample/android/ViewGroup/getChildCount/src/ViewGroup at master · bg1bgst333/Sample · GitHub