1

テキスト付きのラベルの横に配置したいアスタリスクのイメージについて、1日前に質問しました。ただし、画像は2回表示されます.UiBinderとGwtをまだ学習しているため、これを理解するのにまだ苦労しています.

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">

<ui:style type="com.equillore.mcmexternal.client.ui.IndicatorLabel.Style">
    @sprite .mySpriteClass {gwt-image: "imageAccessor"; other: property;}
    .required
     {
        gwt-image: 'requiredImage';
        width: 7px;
        height: 14px;
    }
    .labRequired
    {
        color:#303030;
        font-family: Tahoma, Geneva, sans-serif;
        font-size:10pt;
        font-style:normal;
        font-weight:lighter;
    }
</ui:style>
<g:SimplePanel width='90px' height='21px'>
<g:Grid>
    <g:row>
        <g:customCell>
            <g:Label ui:field="label" addStyleNames="{style.labRequired}"/>
        </g:customCell>
        <g:customCell>
            <g:Label addStyleNames="{style.required}"/>
        </g:customCell>
    </g:row>
</g:Grid>
</g:SimplePanel>

次の行を削除すると

 <ui:image field="requiredImage" src="images/required_indicator.gif"/>

アスタリスクのイメージが正しく表示されるように Java ファイルを変更するにはどうすればよいですか。これが Java ファイルです。

public class IndicatorLabel extends Composite implements HasText {

public interface Binder extends UiBinder<Widget, IndicatorLabel> {
}

private static final Binder binder = GWT.create(Binder.class);

public interface Style extends CssResource {

    String required();
}

@UiField Style style;
@UiField Label label;


public IndicatorLabel() {

    initWidget(binder.createAndBindUi(this));


}

public IndicatorLabel(String text) {

    this();
    setText(text);
}

敬具

4

1 に答える 1

0

クリックできない画像を表示したいだけの場合は、CSS だけを使用してラベルのスタイルを設定することをお勧めします。

@sprite .requiredField 
{
  gwt-image: 'required';
  background-repeat: no-repeat;
  height: 12px;
  width: 150px;
  background-position: right top;
  padding-right:10px;
}

ただし、いずれにしても、次のように、ResourceBundle でイメージを別の方法で定義する必要があります。

@Source("save.png")
public ImageResource required();

これには UIBinder を使用する必要さえありませんが、目的がそれを学ぶことである場合は、次のドキュメントをより厳密にフォローすることをお勧めします: https://developers.google.com/web-toolkit/doc/latest/ DevGuideUiBinder

于 2012-12-06T21:03:22.280 に答える