I am creating a simple calculator for my mobile app that uses a webite to do the
ID: 3550977 • Letter: I
Question
I am creating a simple calculator for my mobile app that uses a webite to do the calculations.
Here is my xml code and the instructions on what to do.
1. You allow user to type in two in operands in the EditText box, and choose one operation using one of the 4 operation buttons. Pay attention to the layout. Basically, you can have multiple table layout to implement the above interface.
2. When the operation button is pressed, you are supposed to use the following webservice for the calculation:
http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx
3. The webservice will return a XML result. You need to extract the result from that XML return, and display the result on the third EditText box.
1. When you are sending the webservice request, you are required to do that with AsyncTask class to avoid ANR (Application Not Responding) dialog.
For the webservice consumption, and XML parsing:
Here is the website i'm supposed to use.
http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#000" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/OperandOneTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/OpernandOne" />
<EditText
android:id="@+id/OperandOneEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" >
<requestFocus />
</EditText>
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/OperandTwoTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/OperandTwo" />
<EditText
android:id="@+id/OperandTwoEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
</TableRow>
</TableLayout>
<TableLayout
android:id="@+id/tableLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#000"
android:shrinkColumns="1,2,3,4" >
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/PlusButton"
style="@string/buttonBarSyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/PlusButton" />
<Button
android:id="@+id/MinusButton"
style="@string/buttonBarSyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MinusButton" />
<Button
android:id="@+id/MultiplyButton"
style="@string/buttonBarSyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/MultiplyButton" />
<Button
android:id="@+id/DivideButton"
style="@string/buttonBarSyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/DivideButton" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</TableRow>
<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/ResultTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ResultTextView" />
<EditText
android:id="@+id/ResultEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
</TableRow>
</TableLayout>
</LinearLayout>
Explanation / Answer
You might wanna share the whole project. It would be easy to debug
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.