停止EditText在活动启动时获得焦点我有一个Activity在Android中,有两个元素:EditTextListView当我Activity开始,EditText立即有输入焦点(闪烁光标)。我不希望任何控制在启动时有输入焦点。我试过:EditText.setSelected(false);没有运气。我怎么才能说服EditText控件时不选择它自己。Activity开始?
4 回答
![?](http://img1.sycdn.imooc.com/545863aa00014aa802200220-100-100.jpg)
慕标琳琳
TA贡献1830条经验 获得超9个赞
android:focusableInTouchMode="true"
<LinearLayout>
<!-- Dummy item to prevent AutoCompleteTextView from receiving focus --><LinearLayout android:focusable="true" android:focusableInTouchMode="true" android:layout_width="0px" android:layout_height="0px"/><!-- :nextFocusUp and :nextFocusLeft have been set to the id of this component to prevent the dummy from receiving focus again --><AutoCompleteTextView android:id="@+id/autotext" android:layout_width="fill_parent" android:layout_height="wrap_content" android:nextFocusUp="@id/autotext" android:nextFocusLeft="@id/autotext"/>
![?](http://img1.sycdn.imooc.com/54586453000163bd02200220-100-100.jpg)
慕姐4208626
TA贡献1852条经验 获得超7个赞
EditText
EditText
EditText
AndroidManifest.xml
<activity> element
android:windowSoftInputMode="stateHidden"
android:windowSoftInputMode="stateUnchanged"
![?](http://img1.sycdn.imooc.com/54584f8f00019fc002200220-100-100.jpg)
一只名叫tom的猫
TA贡献1906条经验 获得超3个赞
创建一个 (我不知道其他布局是否可行) 设置属性 android:focusable="true"
和 android:focusableInTouchMode="true"
EditText
添加回答
举报
0/150
提交
取消