2

创建一个黑莓应用程序。

只是一个初学者,我已经搜索过但找不到解决方案,尽管它很常见。如果有人能告诉我如何在 Java 中为黑莓应用程序显示密码提示和数字提示。提前致谢!!

4

2 回答 2

3
According to your query , you want a field that shows password hint and a numeric hint for blackberry applications ..

Well blackberry follow some different way , it will not show hint (PopUp Screen). Another way is to put some (information) Text in the [EditField][1] when EditField is empty .Here is the sample code for demonstration :-

*******************************************************
    EditField _userName_edtField = new EditField()
        {
            protected void layout(int width, int height) 
            {
                super.layout(width, height);
                setExtent(150, height);
            };
            protected void paint(Graphics graphics) 
            {
                graphics.setColor(Color.BLACK);


                if(isFocus())
                {
                    if(getTextLength() == 0)
                    {
                        setCursorPosition(0);   
                    }
                }
                else
                {
                    if(getTextLength() == 0)
                    {
                        graphics.drawText("User Name", 0, (getHeight() - getFont().getHeight()) >>1);   
                    }
                }


                invalidate();

                super.paint(graphics);
            }
        };

                add(_userName_edtField);

*******************************************************

this is Just a simple EditField , you can customize the field according to your requirement  if this is empty it will show "User Name"  and if you enter some text the "User Name" will disappear ..
means the EditField is act like a Hint and this will help you ..!!!


  [1]: http://www.blackberry.com/developers/docs/5.0.0api/index.html
于 2012-10-02T12:26:27.870 回答
0

您的问题太宽泛,无法得到具体答案,但从我认为您正在谈论文本字段上方或下方的标签来判断,以让用户知道该字段需要什么。在这种情况下,您可以提供一个确认屏幕,向用户显示字段要求,例如字段不能为空,或者该字段只能包含数值等。

您可以将密码提示存储在设备数据库中,当用户输入错误时,会在屏幕上添加标签字段,将其显示为提示。

像这样的东西:

String storedPassword = ApplicationDAO.getStoredPassword();
        if(!enteredPassword.equals(storedPassword)){
           LabelField hintField = new LabelField();
           hintField.setText("Your hint");
           mainBody.add(hintField);
        }
于 2012-09-26T18:36:32.680 回答