我的菜单系统出了问题。四个按钮全部工作正常,但我点击它时,我已经使一个按钮加载错误的活动,但当我点击模拟器的后退按钮然后它加载正确的活动,不希望这我希望它加载正确的活动
这是我为菜单编写的代码
check_view
加载question_view
加载check_view
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
appointment_image_view=(ImageView)findViewById(R.id.appointment_image_view);
check_view=(ImageView)findViewById(R.id.check_view);
questions_view=(ImageView)findViewById(R.id.questions_view);
survey_view =(ImageView)findViewById(R.id.survey_view);
appointment_image_view.setOnClickListener(this);
check_view.setOnClickListener(this);
questions_view.setOnClickListener(this);
survey_view.setOnClickListener(this);
}
public void onClick(View view){
switch (view.getId())
{
case R.id.appointment_image_view:
// open
Intent appointment_intent = new Intent(this,apppointmentactivity.class);
this.startActivity(appointment_intent);
break;
case R.id.check_view:
// open
Intent Health_intent1 = new Intent(this,HealthActivity.class);
this.startActivity(Health_intent1);
case R.id.questions_view:
//open
Intent Question_Intent = new Intent(this,QuestionsActivity.class);
this.startActivity(Question_Intent);
break;
case R.id.survey_view:
Intent Survery_intent = new Intent(this,SurveyActivity.class);
this.startActivity(Survery_intent);
break;
}
}
答案 0 :(得分:1)
此后您缺少break;
:
case R.id.check_view:
// open
Intent Health_intent1 = new Intent(this,HealthActivity.class);
this.startActivity(Health_intent1);
答案 1 :(得分:1)
尝试在break;
添加case R.id.check_view
。