How to hide softinput keyboard from code behind forcefully in xmarine android C#?

Hello,
I am working with Edittext control. I want to hide the keyboard in my activity. I have added this.Window.SetSoftInputMode(SoftInput.StateHidden); from code behind at the time of a button click event. But it is not working.

<EditText
        android:id="@+id/txtKeyWord"
        android:layout_width="280dp"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|left"
        android:textSize="18dp"
        android:background="@android:color/white"
        android:scrollbars="vertical"
        android:inputType="textMultiLine"
        android:imeOptions="flagNoFullscreen"
        android:paddingLeft ="10dp"
            />

how to resolve this issue?

Best Answer

Answers

  • soumenhaldersoumenhalder Member ✭✭

    @jezh said:
    @soumenhalder
    You can try the following code:

           InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
           imm.HideSoftInputFromWindow(edittext.WindowToken, 0);
    

    and make sure to add this library :

           using Android.Views.InputMethods;
    

    Hello @jezh,
    This is working perfect. Thank you.

Sign In or Register to comment.