我有一个有按钮的活动,我想在按下按钮来敬酒时,我这样做了:
public class myActivity extends Activity implements OnClickListener {
EditText nameEditText;
Button okButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
nameEditText = (EditText) findViewById(R.id.editText);
okButton = (Button) findViewById(R.id.button);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.button:
Toast.makeText(myActivity.this, "Pressed", Toast.LENGTH_LONG)
.show();
break;
default:
break;
}
}
}
哪里错了?
谢谢你