Guest User

Untitled

a guest
Dec 14th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. public class MainActivity extends AppCompatActivity {
  2.  
  3. @Override
  4. protected void onCreate(Bundle savedInstanceState) {
  5. super.onCreate(savedInstanceState);
  6. setContentView(R.layout.activity_register);
  7.  
  8. TextView textView = (TextView)findViewById(R.id.textView); //idは自分のレイアウトに合わせて変更
  9.  
  10. EditText editText1 = (EditText)findViewById(R.id.editText1);
  11. EditText editText2 = (EditText)findViewById(R.id.editText2);
  12. Button button = (Button)findViewById(R.id.Button);
  13.  
  14. button.setOnClickListener(new View.OnClickListener() {
  15. @Override
  16. public void onClick(View view) {
  17. String str1 = editText1.getText().toString();
  18. String str2 = editText2.getText().toString();
  19.  
  20. int people = Integer.valueOf(str1);
  21. int money = Integer.valueOf(str2);
  22.  
  23. int result = money / people;
  24.  
  25. String result_str = String.valueOf(result)
  26. textView.setText(result_str);
  27. }
  28. });
  29. }
  30. }
Add Comment
Please, Sign In to add comment