我有一个带有 6 个按钮的表单,我目前正在尝试让第 3 个按钮工作。前两个按钮工作正常,但是当我单击第三个按钮时,什么都没有发生,也没有错误。任何人都可以帮忙吗?
我检查了表单名称、类名称和按钮名称,但无法正常工作。我已经包含了按钮的代码。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setting fullscreen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN );
setContentView(R.layout.main_menu);
initialize(); //calling this method
}
public void initialize(){
//Initializing variables
Film = (Button) findViewById(R.id.bFilm);
Music = (Button) findViewById(R.id.bMusic);
Poets = (Button) findViewById(R.id.bPoet);
Inventors = (Button) findViewById(R.id.bInventors);
Science = (Button) findViewById(R.id.bScience);
Sports = (Button) findViewById(R.id.bSport);
//initialzing onclicklisteners
Film.setOnClickListener(this);
Music.setOnClickListener(this);
Sports.setOnClickListener(this);
}
@Override
public void onClick(View view) {
//case statment for onclicklisteners
try{
switch(view.getId()){
case R.id.bFilm:
Intent film = new Intent(this, Film.class); //open film class
startActivity(film);
break;
case R.id.bMusic:
Intent music = new Intent(this, Music.class); //open music class
startActivity(music);
break;
case R.id.bPoet:
Intent poet = new Intent(this, Poets.class); //open poet class
startActivity(poet);
break;
case R.id.bInventors:
Intent invent = new Intent(this, Inventors.class); //open inventors class
startActivity(invent);
break;
case R.id.bScience:
Intent science = new Intent(this, Science.class); // open science class
startActivity(science);
break;
case R.id.bSport:
Intent sport = new Intent(this, Sports.class); //open sports class
startActivity(sport);
break;
}