2016-07-28 50 views

回答

0

在您的片段託管工具欄,請撥打活動backpress:

@Override 
    public boolean onOptionsItemSelected(MenuItem item) { 
     switch (item.getItemId()) { 
      case android.R.id.home: 
       getActivity().onBackPressed(); 
       break; 
     } 

     return true; 
    } 

要更改圖標返回箭頭,在您的片段:

 ActionBar actionBar = getActivity().getSupportActionBar(); 
     if (actionBar != null) { 
      // Loading the arrow drawable. 
      final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha); // should work 
      actionBar.setHomeAsUpIndicator(upArrow); 
      actionBar.setDisplayHomeAsUpEnabled(true); 
      actionBar.setHomeButtonEnabled(true); 
     } 
+0

謝謝ji ..如果我在fragement中改變後退箭頭 –

+0

@SridharanD添加了代碼來做到這一點 – Shaishav