Advertisement
buzzonit

orcarmobile

Jul 29th, 2016
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <AbsoluteLayout
  3. android:id="@+id/widget0"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. xmlns:android="http://schemas.android.com/apk/res/android">
  7. <EditText
  8. android:id="@+id/v1"
  9. android:layout_width="105dp"
  10. android:layout_height="39dp"
  11. android:textSize="16sp"
  12. android:layout_x="95dp"
  13. android:layout_y="47dp" />
  14. <EditText
  15. android:id="@+id/v2"
  16. android:layout_width="105dp"
  17. android:layout_height="39dp"
  18. android:textSize="16sp"
  19. android:layout_x="95dp"
  20. android:layout_y="86dp" />
  21. <TextView
  22. android:id="@+id/widget37"
  23. android:layout_width="wrap_content"
  24. android:layout_height="20dp"
  25. android:text="valor1"
  26. android:layout_x="27dp"
  27. android:layout_y="56dp" />
  28. <TextView
  29. android:id="@+id/widget37_copy"
  30. android:layout_width="wrap_content"
  31. android:layout_height="20dp"
  32. android:text="valor2"
  33. android:layout_x="27dp"
  34. android:layout_y="92dp" />
  35. <Button
  36. android:id="@+id/soma"
  37. android:layout_width="60dp"
  38. android:layout_height="42dp"
  39. android:text="+"
  40. android:layout_x="31dp"
  41. android:layout_y="175dp"
  42. android:onClick="somar"/>
  43. <Button
  44. android:id="@+id/subtrair"
  45. android:layout_width="58dp"
  46. android:layout_height="43dp"
  47. android:text="-"
  48. android:layout_x="97dp"
  49. android:layout_y="175dp"
  50. android:onClick="subtrair"/>
  51. <Button
  52. android:id="@+id/div"
  53. android:layout_width="57dp"
  54. android:layout_height="42dp"
  55. android:text="/"
  56. android:layout_x="160dp"
  57. android:layout_y="175dp"
  58. android:onClick="divisao"/>
  59. <Button
  60. android:id="@+id/vezes"
  61. android:layout_width="57dp"
  62. android:layout_height="42dp"
  63. android:text="*"
  64. android:layout_x="228dp"
  65. android:layout_y="175dp"
  66. android:onClick="vezes"/>
  67. </AbsoluteLayout>
  68.  
  69.  
  70. ///////////
  71.  
  72. package android.app;
  73.  
  74. import android.os.Bundle;
  75. import android.view.View;
  76. import android.widget.EditText;
  77. import android.widget.Toast;
  78.  
  79. public class MainActivity extends Activity {
  80.  
  81. private EditText edtValor1;
  82. private EditText edtValor2;
  83.  
  84. /**
  85. * Called when the activity is first created.
  86. */
  87. @Override
  88. public void onCreate(Bundle savedInstanceState) {
  89. super.onCreate(savedInstanceState);
  90. setContentView(R.layout.main);
  91.  
  92. edtValor1 = (EditText) findViewById(R.id.v1);
  93. edtValor2 = (EditText) findViewById(R.id.v2);
  94.  
  95. }
  96.  
  97. public void onClick(View v) {
  98.  
  99. }
  100.  
  101. public void subtrair(View v) {
  102. double valor1 = Double.parseDouble(edtValor1.getText().toString());
  103.  
  104. double valor2 = Double.parseDouble(edtValor2.getText().toString());
  105.  
  106. double result = valor1 - valor2;
  107. Toast.makeText(this, "O resultado e" + result, Toast.LENGTH_LONG).show();
  108.  
  109. }
  110.  
  111. public void somar(View v) {
  112. double valor1 = Double.parseDouble(edtValor1.getText().toString());
  113.  
  114. double valor2 = Double.parseDouble(edtValor2.getText().toString());
  115.  
  116. double result = valor1 + valor2;
  117. Toast.makeText(this, "O resultado e" + result, Toast.LENGTH_LONG).show();
  118.  
  119. }
  120.  
  121. public void divisao(View v) {
  122. double valor1 = Double.parseDouble(edtValor1.getText().toString());
  123.  
  124. double valor2 = Double.parseDouble(edtValor2.getText().toString());
  125.  
  126. double result = valor1 / valor2;
  127. Toast.makeText(this, "O resultado e" + result, Toast.LENGTH_LONG).show();
  128.  
  129. }
  130.  
  131. public void vezes(View v) {
  132. double valor1 = Double.parseDouble(edtValor1.getText().toString());
  133.  
  134. double valor2 = Double.parseDouble(edtValor2.getText().toString());
  135.  
  136. double result = valor1 * valor2;
  137. Toast.makeText(this, "O resultado e" + result, Toast.LENGTH_LONG).show();
  138.  
  139. }
  140. }
  141. //////////////////////////////////////////////CALCULADORA
  142. http://professoroscarjr.blogspot.com.br/p/tecmob.html
  143.  
  144.  
  145. http://www.devmedia.com.br/projetando-e-criando-aplicativos-para-dispositivos-moveis/30671
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement