Issue
At some point in my app in need to get views (actually, it should be one) from a layout.
What I know about the layout is it's int
reference, in the form of R.layout.my_layout
.
How can I get the views inside?
I tried getting the root view with
View rootView = (View) getResources().getLayout(R.layout.my_layout)
but obviously it didn't work. getLayout()
returns a XMLResourceParser
object, which I don't know how to manage.
I can't work with IDs.
Solution
Use layout inflater
View rootView = View.inflate(context, R.layout.my_layout, null);
Answered By - SorryForMyEnglish
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.