以编程方式,我在其中定义了一个RelativeLayout
和TextView
(称为标题),如下所示:
RelativeLayout layout = new RelativeLayout(this);
final RelativeLayout.LayoutParams parameters_title =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
title.setLayoutParams(parameters_title);
layout.addView(title,parameters_title);
我打算以后再textviews
补充buttons
。但是现在,我想将其“转换”(我不确定如何将其转化为文字)RelativeLayout
为 aView
以便将其转化为WindowManager
. 我试图这样使用LayoutInflater
,但它不起作用
LayoutInflater layoutInflater =
(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
myView = layoutInflater.inflate(layout, null );
那么目标就是myView
投入WindowManger
通过addView
。我怎样才能View
从我的RelativeLayout
?