【问题标题】:Adding Arbitrary Text Beside Tabs with GWT's TabLayoutPanel使用 GWT 的 TabLayoutPanel 在选项卡旁边添加任意文本
【发布时间】:2011-05-23 20:15:32
【问题描述】:

目前,我有一个带有几个选项卡的 TabLayoutPanel,每个选项卡内部都有一组面包屑。我希望能够在选项卡旁边(在 TabBar 本身内部)显示我的面包屑。我还没有看到有人这样做的任何例子,我开始相信我最终可能会自己重写他们的 TabLayoutPanel 类并在需要的地方实现它,但显然我宁愿不走那条路,除非别无选择.

有人对此有任何指导吗?

【问题讨论】:

    标签: gwt gwt-tablayoutpanel gwt-widgets


    【解决方案1】:

    刚刚遇到同样的问题。这里是大部分相关代码sn-ps。我在选择选项卡时添加了一个 Unicode 箭头,并在取消选择选项卡时删除了它。

        private final String htmlStr ="\u25bb";
    
            private String getTabTitle(String html){
            // Designed to work for this example input.
            //If you pass a different string you will need to do different matching.
            if(html.indexOf("\u25bb") < 0)
                return html;
            else
                return html.substring(html.indexOf("\u25bb")+1);
        }
    
    
        @Override
     public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
            if(!getSelectedIndex().equals(event.getItem())) {
                notifyCurrentTabOfClosing();
                selectedIndex = event.getItem();
                String tabtitle = getTabTitle(getTabBar().getTabHTML(selectedIndex));
                getTabBar().setTabHTML(selectedIndex, htmlStr+tabtitle);
                }
            }
        }
    
    public void selectTab(Widget widget) {
            int widgetIndex = getWidgetIndex(widget);
            selectTab(widgetIndex);
            String tabtitle = getTabTitle(getTabBar().getTabHTML(widgetIndex));
            getTabBar().setTabHTML(widgetIndex, htmlStr+tabtitle);
        }
    

    【讨论】:

    • 感谢您提供此信息。我最终做了一些非常相似的事情,而且效果很好。
    猜你喜欢
    • 2011-07-04
    • 2015-05-29
    • 2011-09-25
    • 2017-12-06
    • 1970-01-01
    • 2015-04-11
    • 2020-01-29
    • 1970-01-01
    • 2013-11-27
    相关资源
    最近更新 更多