在 Blackberry 中的同一水平字段管理器中编辑字段和位图图像

发布于 2024-10-27 13:16:15 字数 1490 浏览 2 评论 0原文

我正在构建一个小型黑莓应用程序,其中我必须在单个水平字段管理器中依次添加编辑字段和位图图像。该代码在以下情况下工作正常 我将位图图像放置在 EditField 之前,但是当我将图像放置在 EditField 之后时,它无法正常工作。

这是我正在使用的代码:

hfm1=new HorizontalFieldManager();

    Bitmap image = Bitmap.getBitmapResource("search_icon.png");
         BitmapField  imageButton = new BitmapField(image, BitmapField.FOCUSABLE)
         {

                    protected boolean navigationClick(int status, int time) 
                    {
                            // This is method will invoke after clicking the image
                            // System.out.println("Image Clicked");
                        SearchButtonClick();
                            return true;
                     }
        };


        searchEdit=new EditField("",_DEFAULT_FIELD_TXT, 50, EditField.FIELD_LEFT|EditField.NO_NEWLINE){

             public void layout(int width, int height)
             {
                    Font font = getFont();
                    int _fieldHeight = font.getHeight()+5;
                    //int _fieldWidth = (getWidth()-100);
                    setExtent(300, _fieldHeight);
                    super.layout(width,height);

              }




         };

         add(new SeparatorField());
         searchEdit.setFont(MainAppScreen.fontTitle);
         searchEdit.setMargin(1, 2,1,1);
         //hfm1.setMargin(2,5,2,5);

         hfm1.add(searchEdit);
         hfm1.add(imageButton);

        add(hfm1);

请建议。 还建议一些在布局管理器中正确对齐组件的方法。

I am building a small Blackberry app in which I have to add an editField and Bitmap Image One after another in a single Horiziontal field Manager. The code works fine when
I am placing Bitmap Image before the EditField but when I am placing the Image after the EditField, Its not working properly.

Here is the code that I am using:

hfm1=new HorizontalFieldManager();

    Bitmap image = Bitmap.getBitmapResource("search_icon.png");
         BitmapField  imageButton = new BitmapField(image, BitmapField.FOCUSABLE)
         {

                    protected boolean navigationClick(int status, int time) 
                    {
                            // This is method will invoke after clicking the image
                            // System.out.println("Image Clicked");
                        SearchButtonClick();
                            return true;
                     }
        };


        searchEdit=new EditField("",_DEFAULT_FIELD_TXT, 50, EditField.FIELD_LEFT|EditField.NO_NEWLINE){

             public void layout(int width, int height)
             {
                    Font font = getFont();
                    int _fieldHeight = font.getHeight()+5;
                    //int _fieldWidth = (getWidth()-100);
                    setExtent(300, _fieldHeight);
                    super.layout(width,height);

              }




         };

         add(new SeparatorField());
         searchEdit.setFont(MainAppScreen.fontTitle);
         searchEdit.setMargin(1, 2,1,1);
         //hfm1.setMargin(2,5,2,5);

         hfm1.add(searchEdit);
         hfm1.add(imageButton);

        add(hfm1);

Please suggest.
Also suggest some way for the proper alignment of components in the layout manager .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烛影斜 2024-11-03 13:16:15

这是一个讨论表格布局的博客 。我认为这是你应该考虑的事情。它使您可以更好地控制布局。

至于上面的代码,我猜想文本框右侧没有足够的空间来显示位图。我认为如果您从位图开始,它将显示整个位图和尽可能多的文本字段。如果您从文本字段开始,它会显示整个字段,并且没有空间显示位图(也许它不会显示部分位图?)

我相信您必须缩小宽度。

Here's a blog that talks about table layout. I think it's something you should consider. It gives you greater control over your layout.

As for your code above, I would guess that there isn't enough space to the right of the textbox to display the bitmap. I think if you start with the bitmap, it will show the entire bitmap and as much of the text field as it can. If you start with the text field it shows the entire field and has no room to show the bitmap (it won't show a partial bitmap, perhaps?)

I believe you'll have to shrink down your widths.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文