选项卡视图有问题,无法设置内容视图
我将在帖子底部链接我的所有文件
我的问题是,我有一个选项卡视图,当前有两个选项卡。 这些选项卡都是一个单独的活动,它扩展了 CustomMenuActivity。这样两个活动就可以共享相同的选项菜单。
在我的选项菜单中,我有一个上一个按钮,因此可以调用另一个方法来设置我的内容视图。这给了我一个 NullPointerException 。
这与我在另一个方法中设置内容视图有关。
有什么办法可以解决这个问题,或者以某种方式解决这个问题吗?
http://pastebin.com/PR7uMTYC - XML file
http://pastebin.com/VsMrMggn - GuideActivity.java
http://pastebin.com/YVdS6P4j - JAndroidTroubleShooter.java
http://pastebin.com/CpjwM07j - CustomMenuActivity.java
I'll link all of my files in the bottom of my post
My problem is that, I have a tab view, currently with two tabs.
These tabs are each a seperate activity, which extends CustomMenuActivity. This is so that both activities can share the same options menu.
In my options menu, I have a previous button, so that, that calls another method, that sets my content view. That gives me a NullPointerException.
It has something to do with the fact that I am setting my content view inside another method.
Is there any way to fix that, or work around it somehow?
http://pastebin.com/PR7uMTYC - XML file
http://pastebin.com/VsMrMggn - GuideActivity.java
http://pastebin.com/YVdS6P4j - JAndroidTroubleShooter.java
http://pastebin.com/CpjwM07j - CustomMenuActivity.java
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要在所有选项卡中使用的菜单完全相同,您可以执行以下操作:
在 TabActivity 本身上。
在 TabActivity 中,您可以像这样获取当前可见的选项卡:
然后确保相关活动实现您的接口并调用相关方法:
Provided that the menu you want in all tabs is exactly the same you can do as follows:
on the TabActivity itself.
In your TabActivity you can get the current visible Tab like this:
Then you make sure that the activity in question implements your interface and call the relevant method: