implements View.OnClickListener
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener((View.OnClickListener) this);
}
//点击按钮获得输入内容
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button:
String inputText = editText.getText().toString();
Toast.makeText(this, inputText, Toast.LENGTH_LONG).show();
break;
default:
break;
}