黑莓的密码和数字提示(java)

时间:2012-09-26 14:37:37

标签: blackberry passwords numeric

创建Blackberry应用程序。

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

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

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

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

这样的事情:

String storedPassword = ApplicationDAO.getStoredPassword();
        if(!enteredPassword.equals(storedPassword)){
           LabelField hintField = new LabelField();
           hintField.setText("Your hint");
           mainBody.add(hintField);
        }