How to implement the functionality of the back button

I have 3 different types of activities, namely category, subcategory and list of items. In sub_category, I created a back button using the Activity intent. The back button in the list of items should be focused on sub_category. i dont know how to do it .. pls guide me ..

+4
source share
2 answers

from the challenge category

Intent it=new Intent(category.this,sub_category.class) startActivityForResult(it); 

similarly

 Intent it=new Intent(sub_category.this,list_item.class) startActivityForResult(it); 

and in the onClickListener back button just finish your activity like

 list_item.this.finish(); 
+6
source

To return to the previous screen, you can call finish () in your current activity. It will remove the current activity from the activity stack and transfer you to the previous one.

0
source

Source: https://habr.com/ru/post/1343726/


All Articles