1

I have the xml layout, and I want to create View from it - I need do it programatically. Is it possible?

1
  • Here you go Commented Nov 4, 2011 at 10:33

2 Answers 2

3

yes It is. you have to use the inflater service like

        LayoutInflater li=(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        yourview=li.inflate(R.layout.yourlayout, null);
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. How can I set width and height for my new view?
with layoutparams. take a look to the documentation.
0

put your xml in layout folder with some name say x.

Use getViewInflate().inflate(R.layout.x, null, null) to create the view.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.