GWT Material DropDown 中的所选项目似乎不像传统 DropDown 那样“粘住”。
第一个问题,这是新 Material 设计的目的吗?难道我做错了什么?我使用的库有问题吗?
其次,无论哪种方式,我都希望所选值取代默认文本。还有比这更好的方法吗?
UIBinder:
<m:MaterialContainer ui:field="materialContainer" paddingLeft="280">
<m:MaterialButton ui:field="areaDropDownButton" text="Area" iconType="ARROW_DROP_DOWN" iconPosition="RIGHT" textColor="white" backgroundColor="green" activates="areaDropDown"/>
<m:MaterialDropDown ui:field="areaDropDown" activator="areaDropDown" constrainWidth="true" />
</m:MaterialContainer>
Java:
this.areaDropDown.addSelectionHandler(new SelectionHandler()
{
@Override
public void onSelection(SelectionEvent event) {
areaDropDownButton.setText(event.getSelectedItem().toString());
}
});
GWT Material 演示: http://gwtmaterialdesign.github.io/gwt-material-demo/#!dropdown
最佳答案
您还可以使用 UiHandler:
@UiHandler("areaDropDown")
void onDropdown(SelectionEvent event){
areaDropDownButton.setText(event.getSelectedItem()).getText());
}
应该可以
关于java - GWT Material - 设置下拉选择文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38674336/