0

Hi am getting strut up while fragment switching one fragment to andthot fragment .. see my code help me....

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();
}

it's working fine when first time then second time it's overlapping

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

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

first time working fine when i tred secoend time add or edit i will overlapping main with add and main with deatil fragments

how to reslove this problem

Bhavik Ambani
  • 6,557
  • 14
  • 55
  • 86
venu
  • 2,971
  • 6
  • 40
  • 59
  • Construct your question properly, otherwise very few solution providers will feel inclined to answer your Question. – The Dark Knight Jun 14 '13 at 13:52
  • ok am expaling flow when i run this code first main Fragmnet --> addListfragment --> conform fragment-->main fragment then after mainFragment -->detailsFragmnet->deitfragment-->mainfragment it's also working then secoend time manifragment --->addfragment then overrlaping addfragment with mainfragmen and same in daetialfragment with mainfragmnet this is problem how to reslove this issue – venu Jun 14 '13 at 13:56
  • I think you need to execute `pendingTransactions` here before you commit . Look at this link : http://stackoverflow.com/questions/15818653/android-fragments-overlap-when-switching-tabs – The Dark Knight Jun 14 '13 at 13:58
  • Also what is your layout style in `activity_main.xml` ? Is it `linear` or `relative` or do you use a `frame layout ` as container ? – The Dark Knight Jun 14 '13 at 14:02
  • i think problem with backstack how to handle back stack i try different ways but still am getting same problem – venu Jun 14 '13 at 14:09

0 Answers0