Android ActionBar Sherlock Swipe Gesture Recogniser

178 Views Asked by At

I have an application that has action bar sherlock and SlidingMenu integrated in it, the application has only 3 pages, and they're static pages, so no big deal about them. I have one activity and 3 fragments that i am changing when using the sliding menu.

What i want to achieve is something like this image

I want the user to be able to swipe with his finger on the ActionBar, and when that happens i change the fragment that is being displayed.

Note: i got the gesture recogniser from this awesome answer, but i can't seem to find a way to attach it to the ActionBar.

If i could put a View on the action bar and detect swipe on it, that would be great, but how can i do that ?!?

One last thing, how to implement this "Page Control" in android ?!?

1

There are 1 best solutions below

0
On

So the answer to my question is that i simply created a custom_actionbar.xml, and then i used this to do the following:

View custom = LayoutInflater.from(this).inflate(R.layout.actionbar_custom, null);
getActionBar().setCustomView(custom);
// and you can use the things in the custom action bar like following !!
Button btnLeft = (Button) custom.findViewById(R.id.btnMenu);

Hope it helps someone :)