Guest User

Untitled

a guest
Apr 27th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.36 KB | None | 0 0
  1. <android.support.design.widget.AppBarLayout
  2. android:id="@+id/appBarLayout"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"
  5. android:theme="@style/AppTheme.AppBarOverlay"
  6. app:layout_constraintTop_toTopOf="parent"
  7. tools:layout_editor_absoluteX="0dp"
  8. tools:ignore="MissingConstraints">
  9.  
  10. </android.support.design.widget.AppBarLayout>
  11.  
  12.  
  13. <android.support.v7.widget.CardView
  14. android:id="@+id/cardfejaum"
  15. android:layout_width="match_parent"
  16. android:layout_height="wrap_content"
  17. android:layout_margin="16dp"
  18. android:layout_marginTop="20dp"
  19. android:elevation="50dp"
  20. app:layout_constraintEnd_toEndOf="parent"
  21. app:layout_constraintHorizontal_bias="0.0"
  22. app:layout_constraintStart_toStartOf="parent"
  23. app:layout_constraintTop_toBottomOf="@+id/appBarLayout">
  24.  
  25. <android.support.v7.widget.Toolbar
  26. android:id="@+id/toolbar"
  27. android:layout_width="match_parent"
  28. android:layout_height="?attr/actionBarSize"
  29. android:background="?attr/colorPrimary"
  30. app:popupTheme="@style/AppTheme.PopupOverlay" />
  31.  
  32. <ImageView
  33. android:id="@+id/fejaum"
  34. android:layout_width="386dp"
  35. android:layout_height="200dp"
  36. android:background="@drawable/fejaum"
  37. android:padding="4dp"
  38. android:src="@color/transparencia"
  39. tools:layout_editor_absoluteX="8dp"
  40. tools:layout_editor_absoluteY="200dp" />
  41.  
  42.  
  43.  
  44.  
  45. <android.support.design.widget.TextInputLayout
  46. android:layout_width="wrap_content"
  47. android:layout_height="wrap_content"
  48. android:layout_marginTop="100dp"
  49. android:textColorHint="#fff"
  50. tools:layout_editor_absoluteX="168dp"
  51. tools:layout_editor_absoluteY="205dp">
  52.  
  53. <android.support.design.widget.TextInputEditText
  54. android:id="@+id/edt"
  55. android:layout_width="200dp"
  56. android:layout_height="wrap_content"
  57. android:backgroundTint="#fff"
  58. android:hint="Comprado:"
  59. android:inputType="number" />
  60.  
  61. </android.support.design.widget.TextInputLayout>
  62.  
  63. <TextView
  64. android:layout_width="wrap_content"
  65. android:layout_height="wrap_content"
  66. android:layout_marginTop="150dp"
  67. android:text="No estoque"
  68. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  69. android:textColor="#fff" />
  70.  
  71. <TextView
  72. android:layout_width="wrap_content"
  73. android:layout_height="wrap_content"
  74. android:text="Feijão"
  75. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  76. android:textColor="#fff"
  77. android:textSize="32sp" />
  78.  
  79. <SeekBar
  80. android:id="@+id/seekBar"
  81. android:layout_width="110dp"
  82. android:layout_height="15dp"
  83. android:layout_marginLeft="160dp"
  84. android:layout_marginTop="158dp"
  85. android:layout_weight="1"
  86. app:layout_constraintEnd_toEndOf="parent"
  87. app:layout_constraintStart_toStartOf="parent"
  88. app:layout_constraintTop_toTopOf="parent"
  89. android:max="4"
  90. android:progressDrawable="@drawable/custom_seek_bar"
  91. android:progress="6"/>
  92. <TextView
  93. android:id="@+id/tvseek"
  94. android:layout_width="wrap_content"
  95. android:layout_height="wrap_content"
  96. android:layout_marginLeft="280dp"
  97. android:layout_marginTop="150dp"
  98. android:text="0"
  99. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  100. android:textColor="#fff" />
  101.  
  102. <TextView
  103. android:id="@+id/tv"
  104. android:layout_width="wrap_content"
  105. android:layout_height="wrap_content"
  106. android:layout_marginLeft="120dp"
  107. android:layout_marginTop="150dp"
  108. android:text="0"
  109. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  110. android:textColor="#fff" />
  111.  
  112. <Button
  113. android:id="@+id/btn"
  114. android:layout_width="wrap_content"
  115. android:layout_height="wrap_content"
  116. android:text="ok"
  117. android:textColor="#fff"
  118. android:layout_marginTop="110dp"
  119. android:layout_marginLeft="200dp"
  120. android:background="@null"/>
  121.  
  122. </android.support.v7.widget.CardView>
  123.  
  124. <android.support.v7.widget.CardView
  125. android:id="@+id/cardarroz"
  126. android:layout_width="0dp"
  127. android:layout_height="wrap_content"
  128. android:layout_marginTop="4dp"
  129. android:elevation="50dp"
  130. app:layout_constraintEnd_toEndOf="@id/cardfejaum"
  131. app:layout_constraintHorizontal_bias="0.0"
  132. app:layout_constraintStart_toStartOf="@id/cardfejaum"
  133. app:layout_constraintTop_toBottomOf="@+id/cardfejaum">
  134.  
  135. <ImageView
  136. android:id="@+id/arroz"
  137. android:layout_width="match_parent"
  138. android:layout_height="200dp"
  139. android:background="@drawable/arrozbranco"
  140. android:padding="4dp"
  141. android:src="@color/transparencia" />
  142.  
  143. <android.support.design.widget.TextInputLayout
  144. android:layout_width="wrap_content"
  145. android:layout_height="wrap_content"
  146. android:layout_marginLeft="160dp"
  147. android:layout_marginTop="130dp"
  148. android:textColorHint="#fff"
  149. tools:layout_editor_absoluteX="168dp"
  150. tools:layout_editor_absoluteY="205dp">
  151.  
  152. <android.support.design.widget.TextInputEditText
  153. android:id="@+id/edtarroz"
  154. android:layout_width="200dp"
  155. android:layout_height="wrap_content"
  156. android:backgroundTint="#fff"
  157. android:hint="Usado:"
  158. android:inputType="number" />
  159.  
  160. </android.support.design.widget.TextInputLayout>
  161.  
  162. <TextView
  163. android:layout_width="wrap_content"
  164. android:layout_height="wrap_content"
  165. android:layout_marginTop="150dp"
  166. android:text="Restante"
  167. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  168. android:textColor="#fff" />
  169.  
  170. <TextView
  171. android:id="@+id/tvarroz"
  172. android:layout_width="wrap_content"
  173. android:layout_height="wrap_content"
  174. android:layout_marginLeft="100dp"
  175. android:layout_marginTop="150dp"
  176. android:text="0"
  177. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  178. android:textColor="#fff" />
  179.  
  180. <TextView
  181. android:layout_width="wrap_content"
  182. android:layout_height="wrap_content"
  183. android:text="Arroz"
  184. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  185. android:textColor="#fff"
  186. android:textSize="32sp" />
  187.  
  188. </android.support.v7.widget.CardView>
  189.  
  190. <android.support.v7.widget.CardView
  191. android:id="@+id/cardaçucar"
  192. android:layout_width="0dp"
  193. android:layout_height="wrap_content"
  194. android:layout_marginTop="208dp"
  195. android:elevation="50dp"
  196. app:layout_constraintEnd_toEndOf="@id/cardfejaum"
  197. app:layout_constraintHorizontal_bias="0.0"
  198. app:layout_constraintStart_toStartOf="@id/cardfejaum"
  199. app:layout_constraintTop_toBottomOf="@+id/cardfejaum">
  200.  
  201. <ImageView
  202. android:id="@+id/açucar"
  203. android:layout_width="match_parent"
  204. android:layout_height="200dp"
  205. android:background="@drawable/acucarrefinado"
  206. android:padding="4dp"
  207. android:src="@color/transparencia" />
  208.  
  209. <android.support.design.widget.TextInputLayout
  210. android:layout_width="wrap_content"
  211. android:layout_height="wrap_content"
  212. android:layout_marginLeft="160dp"
  213. android:layout_marginTop="130dp"
  214. android:textColorHint="#fff"
  215. tools:layout_editor_absoluteX="168dp"
  216. tools:layout_editor_absoluteY="205dp">
  217.  
  218. <android.support.design.widget.TextInputEditText
  219. android:id="@+id/edtaçucar"
  220. android:layout_width="200dp"
  221. android:layout_height="wrap_content"
  222. android:backgroundTint="#fff"
  223. android:hint="Usado:"
  224. android:inputType="number" />
  225.  
  226. </android.support.design.widget.TextInputLayout>
  227.  
  228. <TextView
  229. android:layout_width="wrap_content"
  230. android:layout_height="wrap_content"
  231. android:layout_marginTop="150dp"
  232. android:text="Restante"
  233. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  234. android:textColor="#fff" />
  235.  
  236. <TextView
  237. android:id="@+id/tvaçucar"
  238. android:layout_width="wrap_content"
  239. android:layout_height="wrap_content"
  240. android:layout_marginLeft="100dp"
  241. android:layout_marginTop="150dp"
  242. android:text="0"
  243. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  244. android:textColor="#fff" />
  245.  
  246. <TextView
  247. android:layout_width="wrap_content"
  248. android:layout_height="wrap_content"
  249. android:text="Açucar Refinado"
  250. android:textAppearance="@style/TextAppearance.AppCompat.Large"
  251. android:textColor="#fff"
  252. android:textSize="32sp" />
  253.  
  254. </android.support.v7.widget.CardView>
  255.  
  256. `package org.lucas.aplicativo;
  257.  
  258. import android.support.design.widget.TextInputEditText;
  259. import android.support.v7.app.AppCompatActivity;
  260. import android.os.Bundle;
  261. import android.support.v7.widget.CardView;
  262. import android.text.Editable;
  263. import android.text.TextWatcher;
  264. import android.view.View;
  265. import android.widget.Button;
  266. import android.widget.SeekBar;
  267. import android.widget.TextView;
  268.  
  269. public class Principal extends AppCompatActivity {
  270. CardView cardfejaum, cardarroz, cardaçucar;
  271. TextInputEditText edtarroz, edtaçucar, edt;
  272. TextView tv , tvarroz, tvaçucar, tvseek;
  273. SeekBar seekBar;
  274. Button btn;
  275. int progresso;
  276. @Override
  277. protected void onCreate(Bundle savedInstanceState) {
  278. super.onCreate(savedInstanceState);
  279. setContentView(R.layout.activity_principal);
  280. cardfejaum = findViewById(R.id.cardfejaum);
  281. cardarroz = findViewById(R.id.cardarroz);
  282. cardaçucar = findViewById(R.id.cardaçucar);
  283. edt = findViewById(R.id.edt);
  284. edtarroz = findViewById(R.id.edtarroz);
  285. edtaçucar = findViewById(R.id.edtaçucar);
  286. tv = findViewById(R.id.tv);
  287. tvarroz = findViewById(R.id.tvarroz);
  288. tvaçucar = findViewById(R.id.tvaçucar);
  289. seekBar = findViewById(R.id.seekBar);
  290. tvseek = findViewById(R.id.tvseek);
  291. btn = findViewById(R.id.btn);
  292. seekBar.setProgress(0);
  293. seekBar.setMax(15);
  294. calcular();
  295. seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
  296. @Override
  297. public void onProgressChanged(SeekBar seekBar, int prog, boolean b) {
  298. progresso = prog;
  299. tvseek.setText(" "+prog);
  300. calcular();
  301. }
  302.  
  303. @Override
  304. public void onStartTrackingTouch(SeekBar seekBar) {
  305.  
  306. }
  307.  
  308. @Override
  309. public void onStopTrackingTouch(SeekBar seekBar) {
  310. tvseek.setText(" "+progresso);
  311. calcular();
  312. }
  313. });
  314.  
  315. tv.addTextChangedListener(new TextWatcher() {
  316. @Override
  317. public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  318.  
  319. }
  320.  
  321. @Override
  322. public void onTextChanged(CharSequence s, int start, int before, int count) {
  323.  
  324. }
  325.  
  326. @Override
  327. public void afterTextChanged(Editable s) {
  328.  
  329. }
  330. });
  331. }
  332.  
  333. public void calcular() {
  334. int sub = Integer.parseInt(edt.getText().toString());
  335. int sub2 = Integer.parseInt(tvseek.getText().toString());
  336. int calc = sub - sub2;
  337. tv.setText(String.valueOf(calc));
  338. }
  339. }`
Add Comment
Please, Sign In to add comment