0
votes

I have two fragments like left panel one fragment and right side another fragment having.

The left panel fragment i having the add button from there when i click add button it launches another activity, from this activity i am trying the access the fragment but i am not getting.

This is the code i am using in my activity

LeftFragment left = (LeftFragment) getFragmentManager().findFragmentById(R.id.fragment1); finish();

Can anyone help me.

2
it seems right,but what did u do with "left", you 've just finished your Activity!what do you want to do with your leftfragment?Arash GM
yes, I have the Add button in leftfragement and when clicking add button i am launching another activity from there need to get the leftfragment context.user1584844
sorry i can't help you with this information more,the line of getting fragment is right but i don't know how you are trying to use it,pls provide more information and implementation codeArash GM
Arash, I am having the ListFragment class that with this i have the button for adding new items. When i clicks the add button just launching the another acitvity which has set of fields from here how can i access the ListFragmentuser1584844

2 Answers

0
votes

Well, this because you can't get access to FragmentManager of other Activity, and it`s absolutely normal.

You can simply commit second fragment to the same container as a first one (use single Activity) and use method setCustomAnimations(...) for your transaction to animation.

Good luck!

0
votes

you can define another ListFragment in your Fragment like this:

SecondListFragment SecondListFragment= (SecondListFragment )getFragmentManager().findFragmentById(R.id.second_list_fragment);
SecondListFragment.SetupSecondFragmentList();//its written on onListItemClick in FirstFragment

SetupSecondFragmentList() is a function that setup a list view in my Second ListFragment which has called from first one