Android-7.0: EditText wrong actionId in editor actionlistener

限于喜欢 提交于 2019-12-10 17:36:36

问题


I have an edit text declared in xml like this with following properties and i have set android:imeOptions="actionNext"

<EditText
    android:id="@+id/ui_row_create_poll_edit_text_txt_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="@dimen/margin_normal"
    android:layout_toLeftOf="@id/ui_row_create_task_user_info"
    android:background="@android:color/transparent"
    android:paddingBottom="@dimen/padding_large_plus_little"
    android:paddingLeft="@dimen/padding_large_plus_little"
    android:paddingTop="@dimen/padding_large_plus_little"
    android:singleLine="true"
    android:maxLength="@integer/task_length"
    android:imeOptions="actionNext"
    android:textColor="@color/black"
    android:textSize="@dimen/font_very_large"/>

In code I have added the Editor actionlistener like this.

 public boolean onEditorAction(TextView v, int actionId, KeyEventevent{
    if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT) {
        listener.onActionDone(option, etOption);
    }

In Api < 24 i get actionId as EditorInfo.IME_ACTION_NEXT and it works fine. but when I run my app on Android 7.0 I get actionId as EditorInfo.IME_ACTION_IME_ACTION_UNSPECIFIED

Can somebody point out why i am getting different actionId in Api-24. If there are any changes in editText in Android-7.0 kindly point me to some links. Thanks.

Note: My editText is placed in a listview


回答1:


I have the same problem with using android:imeActionLabel Try remove it and leave default implementation



来源:https://stackoverflow.com/questions/39784856/android-7-0-edittext-wrong-actionid-in-editor-actionlistener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!