How to implement the Android ActionBar back button?

后端 未结 12 2199
天涯浪人
天涯浪人 2020-11-29 15:38

I have an activity with a listview. When the user click the item, the item \"viewer\" opens:

List1.setOnItemClickListener(new OnItemClickListener() {
    @Ov         


        
12条回答
  •  清歌不尽
    2020-11-29 16:03

    Following Steps are much enough to back button:

    Step 1: This code should be in Manifest.xml

    
            
    

    Step 2: You won't give

    finish();
    

    in your Parent Activity while starting Child Activity.

    Step 3: If you need to come back to Parent Activity from Child Activity, Then you just give this code for Child Activity.

    startActivity(new Intent(ParentActivity.this, ChildActivity.class));
    

提交回复
热议问题