Advertisement
Shimmmi

Untitled

Nov 25th, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. public void LvStairs(View view) {
  2.  
  3. TextView lv = (TextView) findViewById(R.id.Lv_stairs);
  4.  
  5. TableLayout table2 = (TableLayout) findViewById(R.id.table2);
  6.  
  7. // values from activity
  8. EditText ta = (EditText) findViewById(R.id.Ta);
  9. String sTa = ta.getText().toString();
  10. double dTa = 0;
  11. try {
  12. dTa = Double.parseDouble(sTa);
  13. } catch (NumberFormatException e) {
  14. ta.setError("Вводите числа, пожалуйста");
  15. }
  16.  
  17. EditText tr = (EditText) findViewById(R.id.Tr);
  18. String sTr = tr.getText().toString();
  19. double dTr = 0;
  20. try {
  21. dTr = Double.parseDouble(sTr);
  22. } catch (NumberFormatException e) {
  23. tr.setError("Вводите числа, пожалуйста");
  24. }
  25.  
  26. double dTs = (dTa + dTr) / 2;
  27. double dps = 353 / dTs;
  28. double dpr = 353 / dTr;
  29. double dpa = 353 / dTa;
  30.  
  31. //get a number of rows in TableLayout
  32. int gsn_count = table2.getChildCount();
  33.  
  34. //initializing an TableRow here
  35. //there i've got an error
  36. TableRow gsnRow = (TableRow) table2.getChildAt(gsn_count);
  37.  
  38. //getting a value from a child in row
  39. TextView tGsn = (TextView) gsnRow.getChildAt(2);
  40.  
  41. String sGsn = tGsn.getText().toString();
  42. double dGsn = 0;
  43. try {
  44. dGsn = Double.parseDouble(sGsn);
  45. } catch (NumberFormatException e) {
  46. tGsn.setError("Ошибка");
  47. }
  48.  
  49. double dLv = 3600 * dGsn / dpa;
  50. double dLvBD = new BigDecimal(dLv).setScale(0, RoundingMode.UP).doubleValue();
  51. String sLvBD = String.valueOf(dLvBD);
  52.  
  53. //set value in a TextView
  54. lv.setText(sLvBD);
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement