public class FullscreenActivity extends AppCompatActivity {
private ImageButton act;
private ImageButton sat;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
act = (ImageButton) findViewById(R.id.act);
sat = (ImageButton) findViewById(R.id.sat);
sat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent(FullscreenActivity.this, sat.class);
startActivity(intent);
act.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent(FullscreenActivity.this, act.class);
startActivity(intent);
}
});
}}
我在做什么?我有一个带有六个图像按钮的主UI,每个图像按钮链接到一个不同的活动。如何在主活动中将所有内容链接到全屏活动
答案 0 :(得分:0)
我认为你想把FullScreenActivity带到前面,所以你只需要完成前面的Activity,因为你没有完成它
只需在sat.class或act.class上执行finish();
...或
您也可以在sat.class或act.class上执行此操作:
Intent i = new Intent(this, FullScreenActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(i);
答案 1 :(得分:0)
act.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent(FullscreenActivity.this, act.class);
startActivity(intent);
}
});
为什么以上部分位于其他按钮的点击监听器中?将它移到匿名内部方法之外,如
sat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent(FullscreenActivity.this, sat.class);
startActivity(intent);
}
});
act.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick (View v) {
Intent intent = new Intent(FullscreenActivity.this, act.class);
startActivity(intent);
}
});