Program and Android application that do simple calculation.
In this first version it does only '+' on integers. In a later exercise you will make another, more flexible calculator.
This user interfaces consists of
android:inputType="numberSigned"
The layout does not have to be as nice as the above - you will make it look nicer very soon ...
When the user clicks the '=' button, the result is calculated and displayed: Make an onClick listener.
Hint: Integer.parseInt(someString)
might be useful.
Change the calculator to use decimal numbers, not integers.
android:inputType
to allow decimal numbers (positive and negative)Double.parseDouble
(someString)
To make the layout look better, like the screen shot at the start of this exercise:
Give the two input fields and the result field all awailable space.
android:layout_weight="1"
android:textAlignment="center"
might also be helpful for some of the fieldsYou have probably tried the calculator application using portrait orientation. Try to change to landscape orientation on your phone or emulator.