Android:更改 TabWidget 中的选项卡顺序/位置
在我的 Android TabWidget 中,我希望能够更改选项卡的索引,以便更改选项卡相对于其他选项卡的顺序或位置。我在文档中没有看到执行此操作的方法。有人有什么想法吗?
我有一个滚动选项卡栏,右侧最后一个选项卡标有“+”。用户单击此按钮可创建新选项卡。但新选项卡始终创建在最右侧,我想将新选项卡插入到“+”选项卡的左侧。
In my Android TabWidget, I would like to be able to change the index of a tab such that the order or position of the tab is changed relative to the other tabs. I don't see a way to do this in the documentation. Anyone have any ideas?
I have a scrolling tab bar with the last tab on the right labeled with "+". The user clicks this to create a new tab. But the new tab is always being created to the far right and I want to insert the new tab just to the left of the "+" tab.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看 TabHost.java。您很可能需要推出自己的 TabHost 并更改 addTab 以获取索引并相应地添加它。
Have a look at TabHost.java. You'll most likely need to roll your own TabHost and alter addTab to take an index and add it accordingly.
您可以扩展 TabHost 并向 addTabWithIndex() 添加您自己的实现吗? TabHost 内部有许多私有数据结构,因此扩展可能无法完全解决您的问题。
Can you extend the TabHost and add your own implementation to addTabWithIndex(). There are many datastructures inside TabHost which are private so extending might not entirely resolve your issue.