I am new to Android code development...I am developing a Android calculator apps and does not understand why the two EditTexts (first input and second input) cannot accept decim
You need to change the input type of your EditText in the XML code.
Change the inputType attribute of the EditText from
android:inputType="number"
to
android:inputType="numberDecimal"
<EditText
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:inputType="numberDecimal"
android:id="@+id/txtOpd1"/>
inputType="number" doesnt allow floats. try changing:
android:inputType="number"
to:
android:numeric="integer|decimal"
If you want to use Decimal Number only on your EditText
use the xml attribute android:inputType="numberDecimal"
in your EditText widget your EditText declaration will be like this:
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
If you want to use Signed Decimal Number than combine the two Xml attributes android:inputType="numberDecimal"
and android:inputType="numberSigned"
. Your EditText declaration will be like this:
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal|numberSigned" >
</EditText>
Change android:inputType from "number" to "numberDecimal". See the documentation for even more options for inputType.