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?
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);
精彩评论