Android Hide soft-keyboard and EditText to non editable

Recently I need to hide the soft-keyboard from popping up when user click or when the app is open first time below is the method which work for me. And make the edit text disabled for editing.



#method 1
 inserting the below code in oncreate method


1
2
3
4
5
6
7
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 //hiding the keyboard
        InputMethodManager im =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        im.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

Then the next thing which is done is to set the edit text clickable , editable, focusable ,focusableInTouchMode to false.




1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="numberDecimal"
       android:id="@+id/editText"
           
            android:clickable="false"
            android:editable="false"
      android:focusable="false"
            android:focusableInTouchMode="false"                   
            />

Comments

Popular posts from this blog

Create Custom View in android MATRIX EFFECT CANVAS tutorial

Xamarin : Simple Calculator Tutorial Visual Studio C#