Android TabHost 示例的问题 [英] Issues with Android TabHost Example

查看:37
本文介绍了Android TabHost 示例的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试实施高级"tabwidget 来自谷歌的例子.但是,当它尝试调用 tabHost.addTab(spec); 时,我会从调试器获得堆栈跟踪.抱歉,我这里没有堆栈跟踪,但我想知道其他人是否也遇到过同样的问题(因为此代码有许多拼写错误和缺失的信息,这使我无法编译.

I have been attempting to implement the 'advanced' tabwidget example from google. But, when it tries to call tabHost.addTab(spec); I get a stack trace from the debugger. Sorry, I don't have the stack trace here, but I'm wondering if others have had this same issue (as this code had a number of typo's and missing information that stopped me from even compiling.

谁能告诉我此代码的更正/运行版本?

Can anyone point me to a corrected/running version of this code?

需要更新的信息是:

<activity android:name=".ArtistsActivity"></activity>
<activity android:name=".AlbumsActivity"></activity>
<activity android:name=".SongsActivity"></activity>

推荐答案

当前 TabHost 示例 包含一个错误,并且还遗漏了一个会阻止示例运行的重要步骤.

The current TabHost Example on the Android Developers site contains one error and also leaves out an important step that will prevent the example from running.

首先:在添加到 HelloTabWidget 类的 onCreate() 方法中,尝试使用名为 mTab​​Host 的 TabHost 对象.这是无效的,应该是tabHost.

First off: In the onCreate() method that is added to HelloTabWidget class attempts to use a TabHost object called mTabHost. This is invalid, it should be tabHost.

第二:本教程省略了将每个活动添加到 AndroidManifest.xml 所需的详细信息.没有这个,代码将无法工作,每次尝试执行时都会强制关闭".

Second: The tutorial leaves out the details that you need to add each of the activities too the AndroidManifest.xml. Without this the code will not work and you will get "force close" each time you attempt to execute.

这篇关于Android TabHost 示例的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆