将其添加到你的代码
android:focusableInTouchMode="true"中将确保你的键盘在启动时不会出现在你的edittext框中。你想将此行添加到包含EditTextBox的线性布局中。你应该可以使用它来解决两个问题。我已经测试过了。简单的解决方案。
即:在你的app_list_view.xml文件中
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:focusableInTouchMode="true"> <EditText android:id="@+id/filter_edittext" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Search" android:inputType="text" android:maxLines="1"/> <ListView android:id="@id/android:list" android:layout_height="fill_parent" android:layout_weight="1.0" android:layout_width="fill_parent" android:focusable="true" android:descendantFocusability="beforeDescendants"/></LinearLayout>
------------------ 编辑:使键盘在启动时出现 -----------------------
这是为了使它们的键盘在启动时出现在用户名edittextbox上。我所做的只是在.xml文件的底部添加了一个空的Scrollview,这将第一个edittext置于焦点并弹出了键盘。我承认这是一个hack,但是我假设你只是想这样做。我已经对其进行了测试,并且效果很好。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="20dip" android:paddingRight="20dip"> <EditText android:id="@+id/userName" android:singleLine="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Username" android:imeOptions="actionDone" android:inputType="text" android:maxLines="1" /> <EditText android:id="@+id/password" android:password="true" android:singleLine="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="Password" /> <ScrollView android:id="@+id/ScrollView01" android:layout_height="fill_parent"android:layout_width="fill_parent"> </ScrollView></LinearLayout>
如果你正在寻找更雄辩的解决方案,那么我发现了这个可以帮助你的问题,它不像上面的解决方案那么简单,但是可能是一个更好的解决方案。我没有测试过,但显然可以。我认为这与你尝试过的解决方案相似,但对你却不起作用。



