在这种情况下,我的 xml 文件显示某种布局,而在运行时生成另一个布局。我非常困惑为什么运行时显示的布局与给定的布局完全不同。这是 xml 文件的代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10" >
<requestFocus />
</EditText>
</LinearLayout>
<Button
android:id="@+id/signUp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign up!" />
</LinearLayout>
这会在标签和按钮上显示“在此处插入名称”。该按钮已正确绑定(bind)并且按下它确实会执行某些操作,但是我无法在运行时在文本字段中输入内容。
最佳答案
这个看起来不错。仔细检查您是否正在使用 Java 代码更改任何属性。
关于java - 我的 .xml 文件布局在模拟中未正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13410497/