mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
dismissSoftInput implemented
This commit is contained in:
@ -51,6 +51,28 @@ export module ad {
|
||||
export function getApplication() { return <android.app.Application>(<any>com.tns).NativeScriptApplication.getInstance(); }
|
||||
export function getApplicationContext() { return <android.content.Context>getApplication().getApplicationContext(); }
|
||||
|
||||
var inputMethodManager: android.view.inputmethod.InputMethodManager;
|
||||
export function getInputMethodManager() {
|
||||
if (!inputMethodManager) {
|
||||
inputMethodManager = <android.view.inputmethod.InputMethodManager>getApplicationContext().getSystemService(android.content.Context.INPUT_METHOD_SERVICE);
|
||||
}
|
||||
return inputMethodManager;
|
||||
}
|
||||
|
||||
export function showSoftInput(nativeView: android.view.View) : void {
|
||||
var imm = getInputMethodManager();
|
||||
if (imm && nativeView instanceof android.view.View) {
|
||||
imm.showSoftInput(nativeView, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
}
|
||||
|
||||
export function dismissSoftInput(nativeView: android.view.View): void {
|
||||
var imm = getInputMethodManager();
|
||||
if (imm && nativeView instanceof android.view.View) {
|
||||
imm.hideSoftInputFromWindow(nativeView.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
export module collections {
|
||||
export function stringArrayToStringSet(str: string[]): any {
|
||||
var hashSet = new java.util.HashSet();
|
||||
|
15
utils/utils.d.ts
vendored
15
utils/utils.d.ts
vendored
@ -66,6 +66,21 @@
|
||||
*/
|
||||
export function getApplicationContext(): android.content.Context;
|
||||
|
||||
/**
|
||||
* Gets the native Android input method manager.
|
||||
*/
|
||||
export function getInputMethodManager(): android.view.inputmethod.InputMethodManager;
|
||||
|
||||
/**
|
||||
* Hides the soft input method, ususally a soft keyboard.
|
||||
*/
|
||||
export function dismissSoftInput(nativeView: android.view.View): void;
|
||||
|
||||
/**
|
||||
* Shows the soft input method, ususally a soft keyboard.
|
||||
*/
|
||||
export function showSoftInput(nativeView: android.view.View): void;
|
||||
|
||||
/**
|
||||
* Utility module dealing with some android collections.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user