简体   繁体   中英

Return to a specific Fragment from a different Activity

I'm making a shopping app using android. I'm currently on the product details Activity and i want to return to my Home Activity with my Product Fragments listing all the Products instead of going back to my Home Activity .

I've tried using super.OnBackPressed() .. and it works however I'm not sure if it's actually a good practice?

 backbtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    ProductDetailActivity.super.OnBackPressed();
                }
            });

I would recomend using library that is part of Android Jetpack - Navigation component. Some additional links official docs , Udacity

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM