开发者

load an xml into the Class View

开发者 https://www.devze.com 2023-01-18 13:22 出处:网络
I am new in android I have created 2 classes.first extends activity and 2nd extends 开发者_高级运维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);
0

精彩评论

暂无评论...
验证码 换一张
取 消