public class MainActivity extends Activity { private Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); button = (Button) findViewById(R.id.buttonId); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // Toast.makeText(MainActivity.this, "你点击了Button", // Toast.LENGTH_SHORT).show(); Intent intent = new Intent(MainActivity.this, SecondActivity.class); startActivity(intent); } }); // buttonListener buttonList = new buttonListener(); // button.setOnClickListener(buttonList); }
以上是代码,测试一下
时间: 2024-10-23 21:16:34