开发者

how to do something like multiple views ..stack in iOS on Android?

开发者 https://www.devze.com 2023-04-02 17:11 出处:网络
I w开发者_C百科as wondering about the following situation: in iOS: I have viewA which goes to viewB on button press. from view B based on some computations, I can either go to viewC or go back to vi

I w开发者_C百科as wondering about the following situation:

in iOS:

I have viewA which goes to viewB on button press. from view B based on some computations, I can either go to viewC or go back to viewA.

I have done this nicely on iOS.

I am wondering how to do the same in Android. Can anyone kindly help me out ? Thanks.


You mean the Task stack on android. Take a look to this, it will be what you're looking for.

For example (I've encapsulate this in a Navigation Manager instance, that handles all my navigation logic, but given your context, something like this could be useful:

Intent intent = new Intent(this.activityC, ActivityA.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); //THIS IS THE TASK MANAGEMENT
if (!params.isEmpty())
    intent.putExtras(params);
this.activity.startActivity(intent);


The Task Stack in Android is correct. If you need to specifically know how to move from one activity to another then just use intents like this to change to a new activity:

    Intent startActivity = new Intent(view.getContext(), TargetActivity.class);
    startActivityForResult(startActivity, 0);
0

精彩评论

暂无评论...
验证码 换一张
取 消