Legna
Legna

Reputation: 468

Nativescript searchBar property keyboardType not working

I have this element:

 <SearchBar
      hint="Search..."
      textFieldHintColor="whitesmoke"
      keyboardType="TYPE_CLASS_NUMBER"

    >
</SearchBar>

But still showing normal keyboard. How can I achieve this?

Upvotes: 0

Views: 109

Answers (1)

Manoj
Manoj

Reputation: 21908

keyboardType is not a valid attribute on SearchBar. But you may able to achieve it by calling setInputType(...) on the native view.

HTML

<SearchBar
      hint="Search..."
      textFieldHintColor="whitesmoke"
     (loaded)="onLoaded($event)"

    >
</SearchBar>

TS

onLoaded(event) {
  if (event.object.android) {
    event.object.android.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
  }
}

Upvotes: 1

Related Questions