问题描述
我使用的是谷歌的例子叫EffectiveNavigation创建ViewPager与标签。问题是,在清单中,我的主要活动,我已设置
I am using the google example called EffectiveNavigation to create a ViewPager with tabs. The problem is that in the manifest, for my main activity, I have set
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
让我的应用程序没有任何动作条。因此,我在
So that my app has no actionBar. Therefore I am getting a NullPointerException at
final ActionBar actionBar = getActionBar();//null from getActionBar()
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);//NullPointerException
现在,我要的是能够创建带有标签的简单ViewPager。而已。没有隆重。我使用谷歌的例子,因为它是我发现了什么。
基本上,在谷歌的例子中,他们使用状态栏来保存标签。我还能有别的可能拥有的标签?任何低于上如何修改护目镜例如一个很好的例子或指令是不会有太大的帮助,因为我不知道很多关于ViewPagers。以谷歌为例的联系是
Now, all I want is to be able to create a simple ViewPager with tabs. That's it. Nothing grand. I am using the google example because it is what I found.Basically in the google example, they are using the statusBar to hold the tabs. How else might I hold the tabs? Anything less than a good example or instruction on how to modify the goggle example is not going to be much help as I don't know much about ViewPagers. The link to the google example is http://developer.android.com/training/implementing-navigation/lateral.html
有一个简单的解决方法状态栏可能就足够了。
A simple workaround the statusBar might be enough.
推荐答案
要其他人到达这里发现@学习者的解决方案不为他们工作,看一看的
To anyone else arriving here finding that @learner's solution doesn't work for them, take a look at http://thepseudocoder.wordpress.com/2011/10/13/android-tabs-viewpager-swipe-able-tabs-ftw/
这篇关于使用ViewPager与标签没有动作条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!