首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >imeOptions="actionSend“不从事材料设计

imeOptions="actionSend“不从事材料设计
EN

Stack Overflow用户
提问于 2019-07-18 16:41:56
回答 2查看 1.1K关注 0票数 3

我想在我的inputText键盘上应用发送操作,但是我仍然看到默认箭头,而不是发送按钮。我还尝试了几种不同版本的设备,但问题依然存在。

XML:

代码语言:javascript
复制
 <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/layout"
        style="@style/AppEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="@dimen/dimen_16"
        android:layout_marginEnd="@dimen/dimen_16"
        app:counterMaxLength="9"
        app:helperText="@string/idnow_landing_helper_text"
        app:helperTextEnabled="true"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="parent">

    <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZ-"
            android:imeOptions="actionSend"
            android:inputType="textCapCharacters"
            android:maxLength="9"
            android:textColor="@color/grayDark"/>
</com.google.android.material.textfield.TextInputLayout>

活动:

代码语言:javascript
复制
 override fun onCreate(savedInstanceState: Bundle?) {
     ...
      findViewById<EditText>(R.id.edit_text).setOnEditorActionListener { v, actionId, event ->
        return@setOnEditorActionListener when (actionId) {
            EditorInfo.IME_ACTION_SEND -> {
                //do things
                true
            }
            else -> false
        }
    }
 }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-07-19 08:05:21

解决办法是增加:

android:singleLine="true"

结果:

代码语言:javascript
复制
<com.google.android.material.textfield.TextInputEditText
            android:id="@+id/edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/white"
            android:imeOptions="actionSend"
            android:inputType="textCapCharacters"
            android:singleLine="true"
            android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZ-"
            android:maxLength="9"
            android:textColor="@android:color/black"/>
票数 4
EN

Stack Overflow用户

发布于 2019-07-18 17:24:23

用下面的TextInputEditText替换

代码语言:javascript
复制
<com.google.android.material.textfield.TextInputEditText
                android:id="@+id/edit_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/white"
                android:imeOptions="actionSend"
                android:inputType="textCapCharacters"
                android:maxLength="9"
                android:textColor="@android:color/black"/>

您将在键盘上获得发送按钮,并在活动中接收回调。

让我知道更多的帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57099210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档