3

有谁知道样式选项卡的教程/示例Ice Cream Sandwich(向左/向右滑动 - 就像在YouTube应用程序中一样)适合向后兼容性支持库。只需要 API 级别 14 或 15。

我的项目只需要Ice Cream Sandwich在我的Galaxy Nexus. 所以我想知道这是如何在不需要向后兼容性的情况下完成的。

谢谢,山姆

4

2 回答 2

2

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).

于 2012-04-12T14:10:42.597 回答
1

我想你已经在你的 API 14+ 设备上实现了一个带有“tabs+swipe”导航的 ActionBar 。整个东西可以适应蜂窝设备之前的设备,因为我只是碰巧自己做了一个演示。

最简单的方法是,基本上,你只需要:

  • 尽可能扩展/导入com.actionbarsherlock类!
  • 尽可能从android.support.v4(而不是通常的android )包导入!

但是,在您执行这些操作之前,您必须首先:

例如(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 {/*...*/} 
于 2012-09-08T22:46:00.150 回答