开发者

not display cursor in custom BasicEditField bb

please check it

BasicEditField demo = ew BasicEditField("", number, 15,
                BasicEditField.FILTER_NUMERIC
                        | Basi开发者_运维知识库cEditField.FIELD_LEFT) {
            public int getPreferredWidth() {
                int Width = Graphics.getScreenWidth() - 180;
                return Width;
            }

            public int getPreferredHeight() {
                return 30;
            }

            public void paint(Graphics g) {

                 g.setColor(Color.LINEN);
                 g.fillRect(0, 0, this.getWidth(), this.getHeight());
                 g.setColor(Color.BLUE);
                 g.drawText(getText(), 0, 0);
                super.paint(g);
            }

            protected void layout(int arg0, int arg1) {
                super.layout(getPreferredWidth(), getPreferredHeight());
                super.setExtent(getPreferredWidth(), getPreferredHeight());
            }
        };

this is my code help me out?


Kalpana, I checked your code. Yes, It is not showing cursor. I suggest you to use EditField instead of BasicEditField. You can override these methods for Editfield also. I tried it and it is showing cursor.


I think I may have solved this by adding another field to the manager before this custom BasicEditField. Add a field that doesn't do anything. Something like this:

BitmapField bugFix = new BitmapField(Bitmap.getBitmapResource("empty_image.png"));
myFieldManager.add(bugFix);
myFieldManager.add(demo);

However, what I found is that the size of the dummy field (BitmapField in this case) matters. If your "empty_image.png" image is only 2px high, only the top 2px of the cursor will display. So, if you can deal with the extra padding, add a field that has at least 20px or so and the entire cursor should display. I should also add that this bug does not seem to show up on any subsequent custom BasicEditFields that you add to the manager... only the first one. Hmmm...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜