英文:
Android skip Activity and put it last
问题
我正在尝试制作一个跳过按钮,它必须执行我所绘制的操作。
老实说,我不知道如何实现这一点。
代码实际上必须跳过当前的活动并将其放在最后。
如果已经回答了活动的问题,就不会有跳过。我在这里绘制
我尝试过一些方法,但超出了我的能力。
Intent intent = new Intent(this, c1_2.class);
startActivity(intent);
finish();
英文:
I am trying to make a skip button and it have to do what i draw.
i honestly don't know how can i make this happen.
The code actually have to skip the current activity and put it as last.
if the activity's question was answered, there is no skip.here i draw
I have tried a few things but it's beyond my powers.
Intent intent=new Intent(this, c1_2.class);
startActivity(intent);
finish();
答案1
得分: 0
你可以使用ArrayList或Queue来保存你的活动,然后使用它来启动Activity。
尝试这个。
final ArrayList<Class> activities = new ArrayList<>();
// 添加你的活动---------------
activities.add(c1_1.class);
activities.add(c1_2.class);
activities.add(c1_3.class);
//----------------------------
butonSkip=findViewById(R.id.skip);
butonSkip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Class firstActivity = activities.get(0);
startActivity(new Intent(c1_1.this,activities.get(0)));
activities.remove(0);
activities.add(firstActivity);
}
});
//-----------可以更改活动数据
// activities.set(1, c1_3.class);
英文:
you can use arrayList or Queue for keep your activityes, then use it to start Activity.
try this.
final ArrayList<Class> activities = new ArrayList<>();
// add your activity---------------
activities.add(c1_1.class);
activities.add(c1_2.class);
activities.add(c1_3.class);
//----------------------------
butonSkip=findViewById(R.id.skip);
butonSkip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Class firstActivity = activities.get(0);
startActivity(new Intent(c1_1.this,activities.get(0)));
activities.remove(0);
activities.add(firstActivity);
}
});
//-----------can change activities data
// activities.set(1, c1_3.class);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论