4

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!

1
  • same problem... searching for an answer for 3 hours Commented Feb 16, 2013 at 20:59

3 Answers 3

4

Got the answer try this:

LayoutInflater inflater = LayoutInflater.from(context); View v = inflater.inflate(R.layout.yourxmllayout, null, false); 
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

-1

You mean like this? http://developer.android.com/guide/topics/ui/custom-components.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.