简体   繁体   中英

WebView & Soft keyboard Issue

I want to show the soft keyboard, until my main activity is destroyed.

I can do this through:

  1. Adding following parameter to a activity tag in my manifest file
 android:windowSoftInputMode="stateAlwaysVisible" 
  1. Adding the following code to activity's onCreate() process:
 EditText editText = (EditText)findViewById(R.id.enter); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)). showSoftInput(editText, InputMethodManager.SHOW_FORCED); 

However, after I add a WebView in my main activity, the situation changes.

When the WebView starts to load the specified url, the soft keyboard disappears.

Or when I click on the WebView, it disappears again. I don't know what's the reason.

Instead of having URL based navigation, check if you can get the HTML and display it using AJAX or Java HTTP URL Connection..

May sound lame but any URL changes would trigger softkeyboard collapse. Actually even if you use loadUrl() method for - javascript:someJSMethod(), even that triggers the softkeyboard collapse as the browser thinks the URL changed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM