Edit text will not post KEYCODE_ENTER to keylistener after setting the digits tag

I have an edit text that I taking only digits and decimals. I want it to also take fractions, and I have gotten this to work. The problem is after setting the digits tag in xml to "0123456789./ " it will no longer post the KEYCODE_ENTER to the listener when the enter button is pressed. Anyone know why this is happening?

<EditText
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:inputType="number|numberDecimal"
     android:digits="1234567890./ "
     android:id="@+id/itsname"
     android:ems="@integer/itslength"
     android:layout_gravity="left|center_vertical" />

Answers


I do not know why they did it this way but you can work around the problem by setting the imeOptions tag in the xml and then adding a OnEditorActionListener to the EditText.

TextView.OnEditorActionListener enterListener = new TextView.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

        switch (actionId) {

            case EditorInfo.IME_ACTION_NEXT:
                Log.e("Listen","TO IT ALL");
                return true;

            default:
                return false;
        }
    }
};

XML:

android:imeOptions="actionNext"

Credit goes to this guy for the answer https://stackoverflow.com/a/25136275/4491275


Need Your Help

C++ - Error: 'list' does not name a type (list object as member variable in class)

c++ class stdlist

I have been running into the "'xxx' does not name a type" error a lot and most posts I've read before have mentioned that this error occurs with some dependency issues. However, I can't seem to find

Java search-Arraylist

java

ArrayList searchList = new ArrayList();