Android 跳过 Activity,将其放在最后

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

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&lt;Class&gt; activities = new ArrayList&lt;&gt;();
    // 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);

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:

确定