Reputation: 1210
I'm wanting to add a LinearLayout
programmatically to my screen. When I call getlayoutInflater().inflate(R.layout.whatever, null)
, will the returned View
always be also a ViewGroup
? What could it ever return that is not a ViewGroup?
Upvotes: 0
Views: 51
Reputation: 43738
The returned view depends on what is defined in the layout as the root view. It can also be a simple view like a TextView
so it is not necessarily a ViewGroup
.
Upvotes: 2
Reputation: 8153
The answer is no. You can check which are ViewGroups
from here: http://developer.android.com/reference/android/view/ViewGroup.html
The basic principle is that ViewGroup
can contain child Views
For example if you inflate layout which has only ImageView
in it. Then that is a View
.
Upvotes: 0