2014-07-13 30 views
0

我想在關閉活動時更改Fragment。我試圖進入活動,FragmentTransaction但它不是正確的方式。我能怎麼做?謝謝Android更改時關閉ActivityDialog

Fragment newFragment = new Ele_Fragment(); 
     FragmentTransaction transaction = getFragmentManager().beginTransaction(); 

     // Replace whatever is in the fragment_container view with this fragment, 
     // and add the transaction to the back stack 
     transaction.replace(R.id.frame_container, newFragment); 
     transaction.addToBackStack(null); 

     // Commit the transaction 
     transaction.commit(); 

回答

0

嘗試添加標籤的addToBackStack強似空

.addToBackStack(Ele_Fragment.TAG); 

這種方式,您有一個鉤到您傳遞的片段。