私は2つの編集とボタンで簡単なアプリを持っていますが、問題は私が何かをしていない間に私のアプリを起動するとソフトキーボードが自動的に表示されることです。 Edittextをクリックすると、ソフトキーボードが表示されますか?もし私がボタンをクリックしたときに、私はいくつかの記事を読んで、これらのことを行うが、彼らはのみ動作している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"/>
ありがとう:
InputMethodManager imm;
imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(username.getWindowToken(),0);
android:descendantFocusability = "beforeDescendants"親のレイアウト –