开发者

Vaadin radio buttons, horizontal rather than stacked vertical

I want to display my radio buttons in 1 line such as:

◎ Option1     ◉ Option2

However with Vaadin I cannot accomplish this it seems like the following,

◎ Option1

◉ Option2

here is my code:

final List<String> options = Arrays.asList(new String[] {
                "hebele", "hubele"});
       开发者_运维知识库 
        final OptionGroup group = new OptionGroup("", options);
        
        group.setNullSelectionAllowed(false); // user can not 'unselect'
        group.select("hubele"); // select this by default

How can i change this?


With Vaadin 7.3, Valo theme supports horizontal OptionGroup without writing custom style:

OptionGroup group = new OptionGroup("", options);
group.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);


As explained in the The Book of Vaadin, you've got to define a theme to setup your own style.css file.

Then you can override the default style for the option to be displayed inline as follow:

.v-app .v-select-optiongroup .v-select-option {
    display:inline;
}


I solved this problem like following.

RadioButtonGroup<String> radioGroupGtip = new RadioButtonGroup<>();
radioGroupGtip.getStyle().set("white-space","nowrap");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜