Jeff
Jeff

Reputation: 1403

load an xml into the Class View

I am new in android I have created 2 classes.first extends activity and 2nd extends View. I want to add buttons,image Views etc. into the second class How can I do this?

Upvotes: 0

Views: 1170

Answers (1)

TuomasR
TuomasR

Reputation: 2316

Take a look at inflate in the View class, this allows you to inflate an arbitrary XML-file which is then added to a specific ViewGroup:

http://developer.android.com/reference/android/view/View.html#inflate(android.content.Context, int, android.view.ViewGroup)

Usage:

View.inflate(context, R.id.my_layout_file, myViewGroup);

Upvotes: 2

Related Questions