[英]android how to add two views into an activity
我想添加一个xml文件和一个将View扩展到单个活动的类,以便它可以同时工作。 如下,
MyActivity
onCreate()
{
RelativeLayout ll= new RelativeLayout(this);
ll.addView(new GraphicsView(this));
ll.--------->how to add main.xml here?
setContentView(ll);// so that i can write like this
}
请解决这个问题。 谢谢
使用布局inflater。 做这样的事......
LayoutInflater inflater = (LayoutInflater) adapterContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.your_xmls, null);
现在将此视图添加到ll。
ll.addView(图)...
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.