Material: - Using EditText, Button, TextView, String to Integer conversion with parseInt, conversion String with toString.
1. Open Eclipse [/ b], create a new project adjusted as shown below:
Spoiler
2. Click Finish, on the left hand side go into the folder layout select main.xml [/ b]
Spoiler
3. That we will create is to make 2 widgets EditText [/ i] as input integer, 4 Button [/ i] for the +, -, *, / and a TextView [/ i] for displays the results of the calculation.
Spoiler
4. After setting the display main.xml , now set the code to hook Main.java with main.xml . Open Main.java .
5. The first do is create a variable of each widget that we have created is [i] Button , [i] EditText and [i] Textview . Create a variable like the following code:
Spoiler
7. After adding [b] setOnClickListener do not forget to implement [b] OnClickListener [/ b].
Spoiler
8. Then create the function [b] onClick for the button can be clicked.
Spoiler
In the above code we first create an integer variable one and two. Because the input of [i] EditText [/ i] form of String so it must be converted to integer with parseInt. Use the switch to set any button to be clicked in accordance +,-,*,/. button Before showing the results of the calculations, it should change back the results of the calculations in the form of an integer to a string by toString ();.
Edited by retry56, 02 March 2011 - 06:35 AM.

















