Analysis of Android keyboard pop up solution

  • 2021-01-02 21:59:36
  • OfStack

An example of Android keyboard pop-up solution is presented in this paper. To share for your reference, the details are as follows:

1, in:

activity android:name=".Uninstaller" android:label="@string/app_name" android:windowSoftInputMode="adjustPan"
To join the:
android:windowSoftInputMode="adjustPan"
It won't automatically pop up the soft keyboard.

PS: This method hides the keyboard, but the interface cannot scroll, even if scrolllayout is used in the layout.

2. To shift the focus to other components, such as Button


button.setFocusable(true); 
button.setFocusableInTouchMode(true); 
button.requestFocus(); 
button.requestFocusFromTouch();

PS: It works.

3. EditText.clearFocus (this method doesn't work at all)

Button in AlertDialog custom view. When you click, you want to hide AlertDialog, but you find that it is not possible. You can only disappear AlertDialog through the three buttons that come with AlertDialog.


// With a cancel button ProgressDialog
downloadDialog = new ProgressDialog(context);
downloadDialog.setCancelable(false);//back Bonding doesn't work , if true, According to the back The key, ProgressDialog disappear 
downloadDialog.setMessage(" Downloading the installation package ...");
downloadDialog.setButton(" cancel ", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int i) {
  dialog.cancel();
  downApkCancel = true;
 }
});

I hope this article has been helpful for Android programming.


Related articles: