codingdir logo sitemap sitemap |
Home
PHP
C#
C++
ANDROID
JAVA
JAVASCRIPT
PYTHON

findFragmentByTag returning null


By : , Category : android

Try using the tag on the activity's FragmentManager directly.

The complete reference of your example seems to be this. Follow this example with more details, you will see that the writer keeps track of tabs and their tag.

ReLated :

Please use Interface and callBack method then resolve your problem.

Your fragment should search for your fragments using the getSupportFragmentManager() instead of the getFragmentManager Method() in your if structure.

BTW, What is that R.id.dish_fragment object? A fragment? A container? It should be a container like a LinearLayout.

You are using the ChildFragmentManager to replace your Fragments right?

That might be your problem, instead of

libraryContainerFragment = (LibraryContainerFragment)fragmentManager.findFragmentByTag("Library");

use

libraryContainerFragment = (LibraryContainerFragment) getChildFragmentManager().findFragmentByTag("Library");

that's because you are using the replace method, that means your first fragment is deleted and replaced, if you want to have both fragments you should use the add method and hide the first one.

Example

FragmentTransaction transaction = manager.beginTransaction();
Fragment secondfragment = FragmentB.newInstance(_provider, null, obj.getdata1(), obj.getdata2());
transaction.add(R.id.fragment_container, secondfragment);
transaction.hide(yourFirstFragmentTAG);
transaction.addToBackStack(null);
transaction.commit(); 
Comments


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © codingdir.com All Rights Reserved .