首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何动态加载GWT主题

如何动态加载GWT主题
EN

Stack Overflow用户
提问于 2015-11-12 10:17:09
回答 1查看 250关注 0票数 0

我有一个基于GWT的国际化应用程序。我想加载GWT主题dynamically.For示例:如果(localhost:8080/GWTApps/app.html)然后加载这个<inherits name='com.google.gwt.user.theme.clean.Clean'/>主题,或者其他(localhost:8080/GWTApps/app.html&local=ar)加载这个<inherits name='com.google.gwt.user.theme.clean.CleanRTL'/>.How来动态地实现这一点,对此有任何想法或想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-12 15:26:35

gwt展示在EntryPoint中这样做。只需添加这些方法并在启动时调用injectThemeStyleSheet()

代码语言:javascript
代码运行次数:0
运行
复制
private native HeadElement getHeadElement() /*-{
    return $doc.getElementsByTagName("head")[0];
}-*/;

/**
* Inject the GWT theme style sheet based on the RTL direction of the current
* locale.
*/
private void injectThemeStyleSheet() {
    //you could inherit any style in your gwt.xml and change the whole theme by changing the THEME string
    //String THEME = "chrome" or "dark" or "standard"
    String THEME = "clean";
    // Choose the name style sheet based on the locale.
    String styleSheet = "gwt/" + THEME + "/" + THEME;
    styleSheet += LocaleInfo.getCurrentLocale().isRTL() ? "_rtl.css" : ".css";
    // Load the GWT theme style sheet
    String modulePath = GWT.getModuleBaseURL();
    LinkElement linkElem = Document.get().createLinkElement();
    linkElem.setRel("stylesheet");
    linkElem.setType("text/css");
    linkElem.setHref(modulePath + styleSheet);
    getHeadElement().appendChild(linkElem);
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33669063

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档