How to place Sherlock ActionBar within Fragment? - android-fragments

How to place Sherlock ActionBar within Fragment?
I already have side-navigation, and all content placed in draggable Fragment. I'm want have ActionBar within fragment, and to drag it at the same time with Fragment.
How to do this?

You don't put an ActionBar in a SherlockFragment. The ActionBar lives outside of the Fragment, and inside your SherlockFragmentActivity.

The solution
ActionBar actionBar = getSherlockActivity().getSupportActionBar();

Related

How to preserve Recycler View content and scroll position in a fragment?

I have a list fragment (containing RecyclerView) and a details fragment. When navigating from list fragment to details fragment and then back to list fragment (using navigation component), the RecyclerView in the list fragment gets recreated which in my case is a bit expensive task and also the scroll position is lost. How can I save the RecyclerView contents and it's scroll position and prevent it from recreating when navigating back to list fragment...

set toolbar on each fragments in viewpager

How to set toolbar on every fragment of viewpager? There is a single fragment with multiple instaces in viewpager have seprate toolbar.
I am stuck in this problem last two days.
Please give me your valuable feedback's.so that i can move forward.

How to place a recyclerview inside a scroll view?

My View has a scroll view, Long enough, and at the bottom, i'm planning to show a comments section, which would basically be a recycler view. Dont know if this is right.
I've created a recycler view and everything as for a normal recycler view, but i'm not able to scroll the items in recycler view.
Please help me out..
Edit:
Found a solution: example link in comment

replace fragments inside fragment displayed by the viewpager

Please see the wireframe image http://i.imgur.com/dPAMA.png first.
I am using a ViewPager to display fragments inside a FragmentActivity. ViewPager gets fragments from the attached FragmentPagerAdapter
mViewPager = (ViewPager) findViewById(R.id.view_pager);
mAdapter = new HomePagerAdapter(getSupportFragmentManager());
mViewPager.setAdapter(mAdapter);
Suppose viewpager has 3 fragments to display say Fragment1, Fragment2, Fragment3.
In the above image 'displaying fragment1' is the title for the first fragment, "Fragment1". This fragment is a list fragment and displays a list. Fragment2 and Fragment3 have their own content to display. when the user swipes on the screen, ViewPager will display the next fragment, "Fragment2".
What i want is that, when an item from the list(displayed by Fragment1) is clicked, Fragment1 should be completely replaced with some other Fragment, say Fragment4 (this is different fragment and is not returned by the attached adapter). when Fragment4 is displayed, the actionbar should change its content. whenever user works on Fragment4 and onBackPress or an action from the ActionBar, Fragment1 with the list should be displayed again. Meanwhile ViewPager should behave the same i.e on swipe, and the next fragment(in our case Fragment2) will be displayed.
basically, i want to get the same behavior as in example at :
http://developer.android.com/training/basics/fragments/fragment-ui.html#Replace
In this example the ListFragment is displayed directly inside a FragmentActivity. I am displaying the ListFragment with a ViewPager. I want the same functionality from the above example but inside fragments displayed with ViewPager. This was very difficult to achieve before the release of Android 4.2. this version of android supports nested fragments using getChildFragmentManager() so, i see some hope.
I am trying this on my side for many days and also scanned entire stackoverflow for Q & A related to nested fragments but didn't get what i want.
So, is this possible to achieve? if yes, then how to?
This was a big problem before Android 4.2 but it seems to easier now with nested fragments, apart from ensuring the back button works. I posted my solution to your question over here: https://stackoverflow.com/a/13925130/467509
My solution answers everything you asked apart from changing the ActionBar.

How to identify the viewcontroller is clicked from More Tab or Separate tab in UITabBarController?

I have the navigationcontroller based viewcontroller and I overriding the root view controller navigation bar back button in to my custom segment control with different purpose. This navigation controller is placed one of the separate tab in the uitabbarcontroller. If this is used as the separate tab bar then no problem.
But if i use this navigationcontroller inside the more option in tabbarcontroller i am not able to come back to the more option list because of backbutton is overridden in my navigationcontroller.
My idea is add one back button only if my navigationcontroller is used more option tab otherwise i need to hidden the back button.
Please help me in this issue?
You can check if a view controller is in the 'more' section as follows:
BOOL isOnMoreNavigationController = [tabBarController.moreNavigationController.viewControllers containsObject:myViewController.navigationController];
From a UI consistency perspective it might be better to always show the back button in its standard position and move your custom buttons to some other place.

Resources