Android hide Keyboard


#1

In my Nativescript app, the application starts with the login page.
And i then ask my user to write his username and password and the keyboard is showing when the user is inputing the fields and then a user clicks “sign in”.
And the user is redirected to another Page with the Keyboard showing.
What i pretend is to the following, as soon the user redirects to another Page i pretend to disable the keyboard. so incase the keyboard moves to another screen the application doesnt crash.
Is there a way to prevent this from happening?


#2

Before submitting the form you can execute the following on a view:


#3

If you want to use the same code for iOS as well as Android, use this:

    // Only works against a specified field!!
    var myTextfield = page.getViewById("myTextFieldId");

    // Works on both ios and android
    myTextfield.dismissSoftInput();

#4

Hope this can help you,

app.component.html

<TextField #imnotf [(ngModel)]="imnumng" keyboardType="number" editable="false" (tap)="seteditableTF()" ></TextField>

app.component.ts

seteditableTF(){
let TFimno = <TextField>this.imnoTF.nativeElement;
TFimno.editable = true;
 }