Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_register);
- TextView textView = (TextView)findViewById(R.id.textView); //idは自分のレイアウトに合わせて変更
- EditText editText1 = (EditText)findViewById(R.id.editText1);
- EditText editText2 = (EditText)findViewById(R.id.editText2);
- Button button = (Button)findViewById(R.id.Button);
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- String str1 = editText1.getText().toString();
- String str2 = editText2.getText().toString();
- int people = Integer.valueOf(str1);
- int money = Integer.valueOf(str2);
- int result = money / people;
- String result_str = String.valueOf(result)
- textView.setText(result_str);
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment