Is requestFocus and focusChange bugged with edittext?

Pedro_MonizPedro_Moniz Member ✭✭
edited December 2018 in Xamarin.Android

Hello, I have just found a really strange behaviour and want to know if it is some kind of bug or just something I have not done well.

I have certain Items on a recycler view. These have edit texts. When the uses presses enter I want to automatically focus the next edit text.

To do this, on OnTextSet I will focus search down and request focus on the next item.

Then the item will get focus and trigger the focusChange event and it will show the keyboard.

Everything works and there is no problem, with one exception. The keyboard only appears in the second edit text if I add text to the first edit text.

For some reason, if I delete text or just accept the text as it is, even though the OnTextset is called and the request focus is called, the focusChange event is NOT called. I also get focus on the second edit text, so why wouldn't the focus change trigger?

This is super strange, it only works when I write more text than I had. What can I be doing wrong?

Best Answer

  • Pedro_MonizPedro_Moniz ✭✭
    edited December 2018 Accepted Answer

    I was already manually handling the next/done actions so this is not an issue for me.

    I have everything working now without the use of the focusableintouchmode.

    I believe the issue may just have spawned from me not using the listeners right away when I was implementing.

    Although it is still very strange and I still do not know why it behaved that way,

Answers

  • Pedro_MonizPedro_Moniz Member ✭✭

    Looks like I had to have both
    _content.Focusable = true;
    _content.FocusableInTouchMode = true;

    Does this mean it is a bug of some sorts? Do not see the reason to have the focusable in touch mode here.

  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    You could try add the following parameter to your EditText:

    android:imeOptions="actionNext"
    android:singleLine="true"
    

    Full explanation here: Android edittext key return goes to next text

  • Pedro_MonizPedro_Moniz Member ✭✭
    edited December 2018 Accepted Answer

    I was already manually handling the next/done actions so this is not an issue for me.

    I have everything working now without the use of the focusableintouchmode.

    I believe the issue may just have spawned from me not using the listeners right away when I was implementing.

    Although it is still very strange and I still do not know why it behaved that way,

  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    @Pedro_Moniz , Could you please post more detailed codes? Or maybe share a basic demo that can reproduce the issue?

Sign In or Register to comment.