android - How to get the reference of a fragment created by FragmentTransaction.replace method -


i added fragment inside activity using following code:

fragmenttransaction ft = getactivity().getsupportfragmentmanager().begintransaction(); ft.replace(r.id.parent_fragment_container, new folderstructurefragment()); ft.commit(); 

my question how can reference of added fragment. have searched lot of key words related fragment , fragmenttransaction didn't find close requirement think basic function , should offered us. appreciated!

try using below code.

folderstructurefragment folderstructurefragment = (folderstructurefragment)getactivity().getsupportfragmentmanager().findfragmentbyid(r.id.parent_fragment_container); 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -