EditText对象的Android问题
我有一个活动,用户将看到一个编辑文本列表。问题是,一旦活动开始,虚拟键盘就会立即启动,用于第一次编辑文本。我不希望这种情况发生,因为在编辑文本之前有一个微调器,我经常发现这样弹出键盘会让用户忘记以前的微调器 以下是相关代码:EditText对象的Android问题,android,android-edittext,spinner,Android,Android Edittext,Spinner,我有一个活动,用户将看到一个编辑文本列表。问题是,一旦活动开始,虚拟键盘就会立即启动,用于第一次编辑文本。我不希望这种情况发生,因为在编辑文本之前有一个微调器,我经常发现这样弹出键盘会让用户忘记以前的微调器 以下是相关代码: <Spinner android:id="@+id/event_location" android:layout_width="fill_parent" android:layout_height="wrap_content" andr
<Spinner
android:id="@+id/event_location"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30px"
android:prompt="@string/location_prompt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Event Name: " />
<EditText
android:id="@+id/event_name"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Activity Type: " />
<Spinner
android:id="@+id/event_type"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Address: " />
<EditText
android:id="@+id/event_address"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
摘要:带有EditText的活动将启动,虚拟键盘将自动弹出。我不希望它这样做,除非用户按下编辑文本
感谢您的帮助。尝试将微调器XML更改为:
<Spinner
android:layout_marginTop="30px"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/event_location"
android:prompt="@string/location_prompt">
<requestFocus />
</Spinner>
请看这篇文章:尝试将微调器XML更改为:
<Spinner
android:layout_marginTop="30px"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/event_location"
android:prompt="@string/location_prompt">
<requestFocus />
</Spinner>
请看这篇文章:编辑文本自动设置为焦点,因此您需要将
android:focusable=“false”
或EditText.setFocusable(false)
设置为焦点,以防止在微调器可见时编辑文本被聚焦。您也可以尝试editText.setSelected(false)
editText会自动设置为焦点,因此您需要将android:focusable=“false”
或editText.setFocusable(false)
设置为焦点,以防止在微调器可见时对editText进行聚焦。您也可以尝试editText.setSelected(false)
这就是我的工作方式:
在xml中,将EditText的focusable属性设置为false:
在
setContent()
方法之后,在所需活动的oncreate()
方法中的code中设置focusable属性:
public void onCreate(捆绑冰柱){
超级冰柱;
setContentView(右布局主视图);
....
EditText et=(EditText)findViewById(R.id.et_注释);
et.setFocusable(真);
et.setFocusableInTouchMode(真);
...
}
这就是它对我的作用:
在xml中,将EditText的focusable属性设置为false:
在
setContent()
方法之后,在所需活动的oncreate()
方法中的code中设置focusable属性:
public void onCreate(捆绑冰柱){
超级冰柱;
setContentView(右布局主视图);
....
EditText et=(EditText)findViewById(R.id.et_注释);
et.setFocusable(真);
et.setFocusableInTouchMode(真);
...
}
好的,当然,我会试试看。有没有一种方法可以让任何东西都没有提示?也就是说,在用户点击某个东西之前,不会“弹出”任何内容。编辑-requestFocus没有更改任何内容。好的,当然,我会尝试一下。有没有一种方法可以让任何东西都没有提示?也就是说,在用户点击某个东西之前,不会“弹出”任何内容。编辑-requestFocus没有更改任何内容。