I have a NavigationViewer
activity which has 3 fragments. I want that every time the user selects an item from NavigationViewer
sliding menu items the app will transact a new fragment object of the selected kind.
for Example I have a NavigationViewer
menu item Called "MyFragment"
So I am trying this Code on that item:
MyFragment myFragment = new MyFragment();
fragmentTransaction.replace(R.id.RR, myFragment , "nav_MyFragment ").commit();
But this causes a problem that if user selected "MyFragment" from menu while it is active [seen to user] it will create a new object. and I want to create that new object only if transacting from some fragment to another.
Any Suggestions?
Edit: retrieving the fragment by tag and then checking if isVisble()
or if isAdded()
gives null exception