这是我的代码,我想点击app icon按钮进入Home活动。我的相同代码适用于HomeActivity按钮。
package com.coderbd.englishtutor;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
public class StudyActivity extends Activity implements OnClickListener{
Button app_icon_topBar;
ImageButton reset;
ImageButton settings;
ImageButton share;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_study);
app_icon_topBar=(Button) findViewById(R.id.app_icon_topBar);
reset=(ImageButton) findViewById(R.id.btn_Reset);
settings=(ImageButton) findViewById(R.id.btn_Settings);
share=(ImageButton) findViewById(R.id.btn_Share);
app_icon_topBar.setOnClickListener(this);
reset.setOnClickListener(this);
settings.setOnClickListener(this);
share.setOnClickListener(this);
}
public void onClick(View v) {
switch(v.getId()){
case R.id.app_icon_topBar:
finish();
setContentView(R.layout.another_home_activity);
break;
case R.id.btn_Reset:
finish();
setContentView(R.layout.activity_contact);
break;
case R.id.btn_Settings:
finish();
setContentView(R.layout.activity_help);
break;
case R.id.btn_Share:
finish();
setContentView(R.layout.activity_scores);
break;
default:
finish();
setContentView(R.layout.another_home_activity);
break;
}
}
请帮帮我。