Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:layout_width="match_parent"
  6. android:layout_height="match_parent"
  7. tools:context=".Distancia">
  8.  
  9. <ScrollView
  10. android:layout_width="match_parent"
  11. android:layout_height="match_parent">
  12.  
  13. <LinearLayout
  14. android:layout_width="match_parent"
  15. android:layout_height="wrap_content"
  16. android:orientation="vertical" >
  17.  
  18. <TextView
  19. android:id="@+id/titulo3"
  20. android:layout_width="match_parent"
  21. android:layout_height="wrap_content"
  22. android:gravity="center"
  23. android:text="Distancia"
  24. android:textSize="30sp" />
  25.  
  26. <TextView
  27. android:id="@+id/subtitulo6"
  28. android:layout_width="match_parent"
  29. android:layout_height="wrap_content"
  30. android:text="Metros A Pies"
  31. android:textSize="18sp" />
  32.  
  33. <TextView
  34. android:id="@+id/textView10"
  35. android:layout_width="match_parent"
  36. android:layout_height="wrap_content"
  37. android:text="Inserte Los Metros" />
  38.  
  39. <EditText
  40. android:id="@+id/Metros"
  41. android:layout_width="match_parent"
  42. android:layout_height="wrap_content"
  43. android:ems="10"
  44. android:inputType="textPersonName" />
  45.  
  46. <Button
  47. android:id="@+id/conMt"
  48. android:layout_width="match_parent"
  49. android:layout_height="wrap_content"
  50. android:text="Convertir Metros A Pies" />
  51.  
  52. <TextView
  53. android:id="@+id/subtitulo7"
  54. android:layout_width="match_parent"
  55. android:layout_height="wrap_content"
  56. android:text="Pies A Metros"
  57. android:textSize="18sp" />
  58.  
  59. <TextView
  60. android:id="@+id/textView12"
  61. android:layout_width="match_parent"
  62. android:layout_height="wrap_content"
  63. android:text="Inserte Los Pies" />
  64.  
  65. <EditText
  66. android:id="@+id/Pies"
  67. android:layout_width="match_parent"
  68. android:layout_height="wrap_content"
  69. android:ems="10"
  70. android:inputType="textPersonName" />
  71.  
  72. <Button
  73. android:id="@+id/conPi"
  74. android:layout_width="match_parent"
  75. android:layout_height="wrap_content"
  76. android:text="Convertir Pies A Metros" />
  77.  
  78. <TextView
  79. android:id="@+id/Resultado1"
  80. android:layout_width="match_parent"
  81. android:layout_height="wrap_content"
  82. android:textSize="24sp" />
  83.  
  84. <TextView
  85. android:id="@+id/Resultado2"
  86. android:layout_width="match_parent"
  87. android:layout_height="wrap_content"
  88. android:textSize="24sp" />
  89. </LinearLayout>
  90. </ScrollView>
  91. </android.support.constraint.ConstraintLayout>
  92.  
  93. Java
  94.  
  95. package com.cecyte.issacinzunza.convertidor;
  96.  
  97. import android.support.v7.app.AppCompatActivity;
  98. import android.os.Bundle;
  99. import android.view.View;
  100. import android.widget.Button;
  101. import android.widget.EditText;
  102. import android.widget.TextView;
  103.  
  104. public class Distancia extends AppCompatActivity {
  105. EditText Metros,Pies;
  106. Button conMt,conPi;
  107. TextView Resultado1,Resultado2;
  108.  
  109. @Override
  110. protected void onCreate(Bundle savedInstanceState) {
  111. super.onCreate(savedInstanceState);
  112. setContentView(R.layout.activity_distancia);
  113. //EditText
  114. Metros = (EditText) findViewById(R.id.Metros);
  115. Pies = (EditText) findViewById(R.id.Pies);
  116. //Botones
  117. conMt = (Button) findViewById(R.id.conMt);
  118. conPi = (Button) findViewById(R.id.conPi);
  119. //TextView
  120. Resultado1 = (TextView) findViewById(R.id.Resultado1);
  121. Resultado2 = (TextView) findViewById(R.id.Resultado2);
  122.  
  123.  
  124. conMt.setOnClickListener(new View.OnClickListener() {
  125. @Override
  126. public void onClick(View v) {
  127. double Metros1 = Float.parseFloat(Metros.getText().toString().trim());
  128. double Resultado01 = (Metros1*3.28);
  129. Resultado1.setText(Resultado01 +" Pies");
  130. }
  131. });
  132. conPi.setOnClickListener(new View.OnClickListener() {
  133. @Override
  134. public void onClick(View v) {
  135. double Pies1 = Float.parseFloat(Pies.getText().toString().trim());
  136. double Resultado02 = (Pies1*0.3048);
  137. Resultado2.setText(Resultado02 +" Metros");
  138. }
  139. });
  140.  
  141.  
  142. }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement