user3280350
user3280350

Reputation: 41

I have an EditText for math expressions and want the default number keyboard to pop up

I have an EditText with inputType = text, because a math expression can be entered.
I would like to have a keyboard that shows numbers along with +, %, - and *.
Not sure what that kind of keyboard is called.
Is there a way for me to set it up without having to change inputType to number.
Thanks!

Upvotes: 0

Views: 1349

Answers (4)

Franklyn
Franklyn

Reputation: 325

<EditText
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:inputType="phone"
  android:digits="0123456789.+-*/"
  android:id="@+id/inputs"
  />

Upvotes: 1

Phant&#244;maxx
Phant&#244;maxx

Reputation: 38098

Use

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="numberDecimal|numberSigned"
    android:digits="0123456789.+-*/%()"
/>

Upvotes: 1

Nambi
Nambi

Reputation: 12042

AndroidDoc Use the inputType numberDecimal|numberSigned for calculator

<EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="numberDecimal|numberSigned" >

</EditText>

Upvotes: 0

Sam
Sam

Reputation: 1662

Try setting input type to your EditText

<EditText android:inputType="number" ... />

EDIT

There's another option for better customization here

Upvotes: 0

Related Questions