Reputation: 121
I am beginning developing android application. What I need to know is how to associated a xml layout file with a new class (not the activity). For example the class needs to have a table with an image and some texts.
thanks!
Upvotes: 4
Views: 6345
Reputation: 2727
You can also write this like:
LayoutInflater inflator = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflator.inflate(R.layout.yourxmllayout, null);
If you are in activity there is no need to use context.
Upvotes: 0
Reputation: 623
Got the answer try this:
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.yourxmllayout, null, false);
Upvotes: 4
Reputation: 22116
You mean like this? http://developer.android.com/guide/topics/ui/custom-components.html
Upvotes: -1