Android 活动组和列表活动
我需要在 TabHost 中的活动中有一个列表。单击按钮时会打开该列表。然而,我希望新活动打开并将选项卡保持在顶部,因此我创建了一个类 TabActivityGroup,它扩展了 ActivityGroup,并且我的每个活动都扩展了 TabActivityGroup。我如何在不扩展 ListActivity 的情况下创建列表,因为我无法扩展两个类。
I need to have a List in an Activity that is in a TabHost. The list gets opened when a button is clicked. I however want the new activity to open up and keep the tabs on top, so I created a class, TabActivityGroup, that extends the ActivityGroup and each of my activities extend TabActivityGroup. How would I create a list without extending ListActivity as I cannot extend two classes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要使用ListActivity。只需进行常规活动即可。在布局文件中执行以下操作:
为列表提供一个 id
在您的活动中使用:
现在您可以使您的活动成为 ActivityGroup
:)
Do not use ListActivity. Just use a regular activity. In the layout file do the following:
Give the list an id
Inside your activity use:
Now you can make your activity be ActivityGroup
:)
嗯,我怀疑你的处理方式是错误的。查看选项卡布局示例。您想要做的是将 ListView 的一些子类添加为 TabHost 视图的子视图,而不是具有多重继承。我建议阅读该教程并重新思考如何构建应用程序。
Hmm, I suspect you're going about this the wrong way. Check out the Tab Layout example. What you want to be able to do is add some subclass of the ListView as a subview of the TabHost view rather than having multiple inheritance. I'd suggest reading through that tutorial and rethinking how you're structuring your app.