首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BlackBerry ChoiceField按钮大小

BlackBerry ChoiceField按钮大小
EN

Stack Overflow用户
提问于 2011-06-10 17:26:15
回答 1查看 586关注 0票数 2

我在我的设计中使用较小的按钮,我想要一个带有较小按钮的ChoiceField。按钮技术不能像我期望的那样在ChoiceField上工作。我可以更改大小,但按钮呈现不正确。如何更改ChoiceField中按钮的大小?

代码语言:javascript
复制
ChoiceField choiceMode = 
    new ChoiceField(
        searchModel.getPickerLabel(SearchOptions.PICKER_MODE),modes.length,0) {
            public Object getChoice(int index) throws IllegalArgumentException {
                return modes[index];
            }

            public int getPreferredHeight() {
                return 40;
            }

            protected void layout(int width, int height) {
                super.layout(width, 40);
                setExtent(width, 40);
            }
        };
EN

回答 1

Stack Overflow用户

发布于 2011-07-15 01:45:23

我使用这个类::

代码语言:javascript
复制
    public class JOChoiceField extends ObjectChoiceField {
        int setWidth;
        int setHeight;

        public JOChoiceField (String text, Object[] choices, long setStyle, int initIndex, int pSetWidth, int pSetHeight) {
            super(text, choices, initIndex, setStyle);
            setWidth = pSetWidth;
            setHeight = pSetHeight;
        }           
        public int getPreferredWidth() {
            return setWidth;
        } 
        public int getPreferredHeight() {
            return setHeight;
        }           
        public void getFocusRect(XYRect rect) {        
          rect.set(getFont().getAdvance(getLabel()), 0, setWidth, setHeight);    
        }    
        protected void layout(int width, int height) {
            int useWidth;
            int useHeight;

            useWidth = getPreferredWidth();
            useHeight = getPreferredHeight();

            setExtent(setWidth, setHeight);
            super.layout(useWidth, useHeight);          
        }                   
};

--

代码语言:javascript
复制
MyCustomChoiceField= new JOCChoiceField("",MyArrayofItems,ObjectChoiceField.FIELD_LEFT|ObjectChoiceField.FOCUSABLE,0,100,50);           
MyCustomChoiceField.setChangeListener(this);                
MyCustomChoiceField.setFont(Font.getDefault().derive(Font.BOLD,6,2));       
add(MyCustomChoiceField);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6304442

复制
相关文章

相似问题

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