My layout is like below and I don't want the edittext2 to show above the keyboard when I type in the edittext1(not the keyboard, just the edittext2). And maintain the current status when type in the edittext2
Asked
Active
Viewed 156 times
0
-
https://stackoverflow.com/questions/9732761/how-to-avoid-automatically-appear-android-keyboard-when-activity-start/34635955 – John Joe Apr 19 '18 at 02:45
-
Is this a list? – Khemraj Sharma Apr 19 '18 at 03:04
-
yeah, a recyclerlist – xiaohanhan Apr 19 '18 at 03:14
-
Remove this line from manifest - android:windowSoftInputMode="adjustPan" – Dnyaneshwar Panchal Apr 19 '18 at 03:37
2 Answers
0
Remove this line from your manifest file.
android:windowSoftInputMode="adjustPan"

Dnyaneshwar Panchal
- 444
- 4
- 13
0
try this:
Add java class
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_edit_name, container);
editText = (EditText) view.findViewById(R.id.txt_yourName);
// Request focus and show soft keyboard automatically
editText.requestFocus();
getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
return view;
}
Another solution
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
editText.post(new Runnable() {
@Override
public void run() {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});
}
});
editText.requestFocus();

Android Geek
- 8,956
- 2
- 21
- 35
-
Thank you, but it makes no sense.I just want to hide the edittext2 when i type something in the edittext1, not hide the keyboard, just hide the edittext2. – xiaohanhan Apr 20 '18 at 13:41