Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
EditText对象的Android问题_Android_Android Edittext_Spinner - Fatal编程技术网

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:
  • android:focusable=“false” 二,。为了使EditText在启动后再次可聚焦:
    setContent()
    方法之后,在所需活动的
    oncreate()
    方法中的code中设置focusable属性:

    public void onCreate(捆绑冰柱){
    超级冰柱;
    setContentView(右布局主视图);
    ....
    EditText et=(EditText)findViewById(R.id.et_注释);
    et.setFocusable(真);
    et.setFocusableInTouchMode(真);
    ...
    }  
    
    这就是它对我的作用:

  • 要确保编辑文本不会在启动时获得焦点:
    在xml中,将EditText的focusable属性设置为false:
  • android:focusable=“false” 二,。为了使EditText在启动后再次可聚焦:
    setContent()
    方法之后,在所需活动的
    oncreate()
    方法中的code中设置focusable属性:

    public void onCreate(捆绑冰柱){
    超级冰柱;
    setContentView(右布局主视图);
    ....
    EditText et=(EditText)findViewById(R.id.et_注释);
    et.setFocusable(真);
    et.setFocusableInTouchMode(真);
    ...
    }  
    
    好的,当然,我会试试看。有没有一种方法可以让任何东西都没有提示?也就是说,在用户点击某个东西之前,不会“弹出”任何内容。编辑-requestFocus没有更改任何内容。好的,当然,我会尝试一下。有没有一种方法可以让任何东西都没有提示?也就是说,在用户点击某个东西之前,不会“弹出”任何内容。编辑-requestFocus没有更改任何内容。