3

を使用して複数のウィジェットで CSS を共有したいと考えています。

css クラス名が難読化されていることがわかりますが、firefox / chrome で要素を調べると、クラス定義が表示されません。これが私のコードです。誰かが私が欠けているものを提案できますか? ありがとう。

スタイル.css

.nameSpan {  color: #3E6D8E; background-color: #E0EAF1;} 

リソース.java

public interface Resources extends ClientBundle { 
  @Source("Style.css") 
  Style style(); 
  public interface Style extends CssResource { 
    String nameSpan(); 
  } 
} 

uibinder.ui.xml

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' 
    xmlns:g='urn:import:com.google.gwt.user.client.ui'> 
  <ui:with field='res' type='com.my.app.widgets.logoname.Resources'/> 
  <g:HTMLPanel> 
      <div> 
        Well hello there 
        <g:InlineLabel ui:field='nameSpan' styleName="res.style.nameSpan">kevin</g:InlineLabel>
      </div> 
  </g:HTMLPanel> 
</ui:UiBinder> 

uibinder.class

public class uibinder extends Composite { 
        private static uibinderUiBinder uiBinder =     GWT.create(uibinderUiBinder.class); 
        interface uibinderUiBinder extends UiBinder<Widget, uibinder> {} 
        @UiField(provided = true)  final Resources res;  // the style doesn't show no matter provided=true is declared or not. 
        public uibinder(Resources res) { 
                res = GWT.create(Resources.class); 
                initWidget(uiBinder.createAndBindUi(this)); 
        } 
4

2 に答える 2

7

使用する必要がありますres.style().ensureInjected()

于 2010-11-26T02:57:55.930 に答える
2

styleNameどこかにスタイル(属性)を割り当てる必要があります。例えば:

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'> 
    <ui:with field='res' type='com.my.app.widgets.logoname.Resources'/> 
    <g:HTMLPanel> 
        <div> 
            Well hello there 
            <g:InlineLabel ui:field='nameSpan' styleName="{res.nameSpan}">kevin</g:InlineLabel>
        </div> 
    </g:HTMLPanel> 
</ui:UiBinder>

宣言した属性ui:fieldはcssスタイルを設定しません。クラスに入力する属性を定義しますuibinder。ガイダンスについては、 GWTドキュメントを参照してください。

于 2010-11-15T11:05:21.130 に答える