2023年7月7日发(作者:)
phonegap: How to show and hide soft keyboard inAndroidCreate a class that handles the keyboard
import ap;import t;import ethodManager;import w;public class KeyBoard { private WebView mAppView; private DroidGap mGap; public KeyBoard(DroidGap gap, WebView view) { mAppView = view; mGap = gap; } public void showKeyBoard() { InputMethodManager mgr = (InputMethodManager)temService(_METHOD_SERVICE); // only will trigger it if no physical keyboard is open ftInput(mAppView, _IMPLICIT);
((InputMethodManager)temService(_METHOD_SERVICE)).showSoftInput(mAppView, 0);
}
public void hideKeyBoard() { InputMethodManager mgr = (InputMethodManager)temService(_METHOD_SERVICE); ftInputFromWindow(dowToken(), 0); }}In your main activity add a Javascript interface for this class:
import ;import ap.*;public class Mobile_PG extends DroidGap { @Override public void onCreate(Bundle savedInstanceState) {
te(savedInstanceState); KeyBoard keyboard = new KeyBoard(this, appView); ascriptInterface(keyboard, "KeyBoard"); l("file:///android_asset/www/"); }}
From the javascript you now can call yBoard(); to show the soft keyboard and if needed you can hideit with yBoard();
I copy the android_ file into my and then ant compile and ant install. This is how the looks like:
发布者:admin,转转请注明出处:http://www.yc00.com/web/1688678325a161809.html
评论列表(0条)