Search code examples
androidimeoptions

imeOptions not working for CustomEditText


I need to set imeOptions on my CustomEditText. But the imeOptions is not available.

My CustomEditText:

public class CustomEditText extends AppCompatEditText {
    private Context context;

    public CustomEditText(Context context) {
        super(context);
        this.context = context;
    }

    public CustomEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    public CustomEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
    }
}

Solution

  • Your CustomEditText code is woking fine in my devive

    You need to set android:inputType="text" with android:imeOptions="actionNext"

    You can set inputType and imeOptions as per your requirement

    Check this below example

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <com.example.nilesh.testapp.CustomEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:imeOptions="actionNext"
            android:inputType="text" />
    
        <com.example.nilesh.testapp.CustomEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:imeOptions="actionNext"
            android:inputType="text" />
    
        <com.example.nilesh.testapp.CustomEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:imeOptions="actionNext"
            android:inputType="text" />
    
        <com.example.nilesh.testapp.CustomEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:imeOptions="actionNext"
            android:inputType="text" />
    
        <com.example.nilesh.testapp.CustomEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:imeOptions="actionNext"
            android:inputType="text" />
    
    </LinearLayout>