我在我的活动中使用开关盒。我正在使用 6 个案例,他们打开相同的活动 Map.java。现在在 Map.java 中,我想从哪个按钮打开这个活动并想在那里执行 toast。请给我指路。提前谢谢。这是我的代码
public void buttonClick(View v) {
switch (v.getId()) {
case R.id.imageButton1:
img3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Report.this, Map.class));
}
});
break;
case R.id.imageButton2:
img4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Report.this, Map.class));
}
});
break;
case R.id.imageButton3:
img5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Report.this, Map.class));
}
});
break;
case R.id.imageButton4:
img6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Report.this, Map.class));
}
});
break;
case R.id.imageButton5:
img7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Report.this, Map.class));
}
});
break;
case R.id.imageButton6:
img8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(Report.this, Map.class));
}
});
break;
}
}