【发布时间】:2014-03-27 09:23:51
【问题描述】:
当更改第一个视图的TextView的文本时,第二个视图的textView的文本显示两个TextView的文本,一个在另一个之上。
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FrameLayout rl=(FrameLayout) findViewById(R.id.mainLayout);
View v1=LayoutInflater.from(this).inflate(R.layout.text_view, null);
View v2=LayoutInflater.from(this).inflate(R.layout.text_view, null);
TextView myTextView1= (TextView) v1.findViewById(R.id.myTextView);
TextView myTextView2= (TextView) v2.findViewById(R.id.myTextView);
myTextView1.setText("str1");
myTextView2.setText("str2");
rl.addView(v1);
rl.addView(v2);
}
【问题讨论】:
-
布局?代码?有什么可看的吗?
-
您正在使用框架布局,目标是让视图重叠吗?
-
不,我在标签中使用它,每个视图属于不同的标签,我没有发布我的所有代码。
标签: android android-button layout-inflater