0
我有一個實現onClickListener
的片段,然後onClickListener
嘗試刪除片段。刪除另一個片段活動中的片段
我在transaction.remove(badFragment);
的badFragment
下得到一條紅線。我最好的猜測是因爲它無法確定這個片段是什麼/它在哪裏。
我該如何去尋找這個片段,以便它可以被刪除?
我試過findFragmentId(badFragment);但它不起作用。
獎勵積分如果你能讓我知道你在哪裏找到這種方法。由於我不擅長在Android文檔中查找內容。
謝謝。我的問題是,我從來沒有定義壞片段...愚蠢的我。 'Bad_fragment badFragment = new Bad_fragment();'謝謝你的迴應! – EGHDK 2012-08-04 21:56:11
對於獎勵積分:['findFragmentById'](http://developer.android.com/reference/android/app/FragmentManager.html#findFragmentById(int))+ ['FragmentTransaction'](http:// developer .android.com /參考/機器人/應用/ FragmentTransaction.html#刪除(android.app.Fragment))。 – Eric 2012-08-04 21:56:41