我有两个编辑文本,第一个总是有焦点。我试过clearFocus()但它不起作用。
xml是这样的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/barcode"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/enterbarcode" >
</EditText>
<View
android:layout_width="fill_parent"
android:layout_height="10dp" >
</View>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/or"
android:textAppearance="?android:attr/textAppearanceMedium" >
</TextView>
<View
android:layout_width="fill_parent"
android:layout_height="10dp" >
</View>
<EditText
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/entername" >
</EditText>
<Button
android:id="@+id/ok"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="@drawable/button"
android:text="@string/forward"
android:textStyle="bold" >
</Button>
</LinearLayout>
我在这里读到了一个关于虚拟项目的答案,但我不知道如何将它应用到我的特定xml中。