Android 跳过 Activity,将其放在最后

huangapple go评论118阅读模式
英文:

Android skip Activity and put it last

问题

我正在尝试制作一个跳过按钮,它必须执行我所绘制的操作。
老实说,我不知道如何实现这一点。
代码实际上必须跳过当前的活动并将其放在最后。
如果已经回答了活动的问题,就不会有跳过。我在这里绘制
我尝试过一些方法,但超出了我的能力。

  1. Intent intent = new Intent(this, c1_2.class);
  2. startActivity(intent);
  3. 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.

  1. Intent intent=new Intent(this, c1_2.class);
  2. startActivity(intent);
  3. finish();

答案1

得分: 0

你可以使用ArrayList或Queue来保存你的活动,然后使用它来启动Activity。

尝试这个。

  1. final ArrayList<Class> activities = new ArrayList<>();
  2. // 添加你的活动---------------
  3. activities.add(c1_1.class);
  4. activities.add(c1_2.class);
  5. activities.add(c1_3.class);
  6. //----------------------------
  7. butonSkip=findViewById(R.id.skip);
  8. butonSkip.setOnClickListener(new View.OnClickListener() {
  9. @Override
  10. public void onClick(View v) {
  11. Class firstActivity = activities.get(0);
  12. startActivity(new Intent(c1_1.this,activities.get(0)));
  13. activities.remove(0);
  14. activities.add(firstActivity);
  15. }
  16. });
  17. //-----------可以更改活动数据
  18. // activities.set(1, c1_3.class);
英文:

you can use arrayList or Queue for keep your activityes, then use it to start Activity.

try this.

  1. final ArrayList&lt;Class&gt; activities = new ArrayList&lt;&gt;();
  2. // add your activity---------------
  3. activities.add(c1_1.class);
  4. activities.add(c1_2.class);
  5. activities.add(c1_3.class);
  6. //----------------------------
  7. butonSkip=findViewById(R.id.skip);
  8. butonSkip.setOnClickListener(new View.OnClickListener() {
  9. @Override
  10. public void onClick(View v) {
  11. Class firstActivity = activities.get(0);
  12. startActivity(new Intent(c1_1.this,activities.get(0)));
  13. activities.remove(0);
  14. activities.add(firstActivity);
  15. }
  16. });
  17. //-----------can change activities data
  18. // activities.set(1, c1_3.class);

huangapple
  • 本文由 发表于 2020年4月7日 00:25:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/61064401.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定