Reputation: 2513
Does anyone know of a tutorial/example for Ice Cream Sandwich
style tabs (with swipe left/right - like in the YouTube
app) that isn't for the backward compatibility support library. Just need API level 14 or 15.
My project only has to work on Ice Cream Sandwich
on my Galaxy Nexus
. So I'd like to know how this is done without needing backward compatibility.
Thanks, Sam
Upvotes: 3
Views: 2876
Reputation: 261
I presume you have achieved an ActionBar with "tabs+swipe" navigation on your API 14+ device. the whole thing can be adapted to pre-Honeycomb devices, since I just happened to have made a demo for that myself.
The most easy way is, basically, you just have to:
However, before you can do those, you would have to have to first:
For example (MainActivity.java):
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
public class MainActivity extends SherlockFragmentActivity implements ActionBar.TabListener {/*...*/}
Upvotes: 1
Reputation: 6591
Well, there's not really a reason to specifically avoid backwards compatibility, since if you don't want older devices using it, you can specify the minimum API version in the manifest for your app.
That said, the ViewPager
is the way that Google does it, and it leverages Fragments
, which while they are backwards compatible, are built into Android 4.
If you don't care to use Fragments
but just want to swipe from View
to View
, you can use a regular PagerAdapter
with it instead of a FragmentPagerAdapter
, or you could use a ViewFlow
.
The example on the ViewFlow page is for support v4, but there are also some examples here for API 13+ which may be closer to what you're looking for (this one in particular).
Upvotes: 2