片段切换重叠android

时间:2013-06-14 13:48:35

标签: android android-fragments

当你将一个片段切换到andthot片段时,你得到了支持。 看我的代码帮助我......

MainActivity
-------------------


// adding new item

addItem()
{
FragmentManager mFragmentManger = getFragmentManager();

FragmentTransaction transaction = mFragmentManager.beginTransaction();
transaction.remove(mFragmentManager.findFragmentByTag(Constants.TAG_LIST));

Fragment fragmentAdd = new AddFragment(mFragmentManager);

transaction.add(R.id.ListLayout, fragmentAdd,"AddNew").addToBackStack()
                .commit();
}

// Detailsfragment listItem 

editItem()
{
transaction.remove(mFragmentManager.findFragmentByTag(Constants.TAG_LIST));

Fragment editFragment = new Detailsfragment(mFragmentManager);

transaction.add(R.id.ListLayout, Detailsfragment).addToBackStack(null).commit();


}





AddFragment
---------------------

nextButton()
{
CoformFragment confrom = new CoformFragment();

transaction.remove(mFragmentManager.findFragmentByTag("AddNew"));
transaction.add(R.id.ListLayout, fragment,"coform").addToBackStack(null).commit();

}


CancelButton()
{
mFragmentManeger.popBackStack();

}



CoformFragment
----------------------

conformButton()
{
transaction.remove(mFragmentManager.findFragmentByTag("Number"));
Fragment listFragmrnt = mFragmentManager.findFragmentByTag(Constants.TAG_LIST);

transaction.replace(R.id.ListLayout, listFragment).commit();

}

backButton()
{
mFragmentManeger.popBackStack();

}




Detailsfragment
------------------

showListDetails()
{
mFragmentManager.beginTransaction().replace(R.id.listLayout, fragment).commit();

}



EditFragment
-------------------

confromButton()
{

updated values

then

Detailsfragment fragment = new Detailsfragment();

mFragmentManager.beginTransaction().replace(R.id.listLayout, fragment).commit();

}

cancelButton()
{

mFragmentManager.beginTransaction().replace(R.id.listLayout, fragment).commit();
}

第一次第二次重叠时工作正常

main-->add->>confrom-->main

main-->details-->edit-->main

第一次工作正常,当我添加或编辑secoend时,我将重叠主要与add和main与deatil片段

如何重新解决这个问题

0 个答案:

没有答案