I have a simple app with 2 edits and a button, the problem is that when I start running my app, the soft keyboard automatically appears while I have not do anything. I want to when I click on Edittext, soft keyboard will appears? Thank you all
MainActivity.xml
<EditText
android:id="@+id/username"
android:hint="Email/Phone"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/password"
android:hint="Password"
android:inputType="textPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/btn_login"
android:text="Login"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
I have read some post and do these things, but they only work when I click the button:
InputMethodManager imm;
imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(username.getWindowToken(),0);