Skip to content

Instantly share code, notes, and snippets.

@sansuke05
Last active December 12, 2017 09:49
Show Gist options
  • Save sansuke05/8f2ba9e7df9681e5f642863bcde1760b to your computer and use it in GitHub Desktop.
Save sansuke05/8f2ba9e7df9681e5f642863bcde1760b to your computer and use it in GitHub Desktop.
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);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment