如何在XML中设置正确的键盘类型?

时间:2013-05-01 05:54:23

标签: mobile

我在屏幕上定义了多个编辑字段。他们采用名字,姓氏,电子邮件和我们的邮政编码。如何在焦点开启时更改键盘

  • firstname和lastname - 首字母大写
  • 电子邮件 - 键盘显示符号“@”和“.com”
  • us zipcode - 键盘只显示数字。

    <screens>
        <screen name="userprofile" screen_type="SCREEN" allow_reorientation="true" allowed_layouts="BOTH" scroll="VERTICAL"
                width="100" height="100" local_data_source="select lastname, firstname, email, zipcode from user_details where email=&apos;&lt;email&gt;&apos;" >
            <title_controls>
                <control type="TEXT" x="0" y="1" width="100" height="6" default_value="Profile" 
                        appearance_name="white" data_type="VARCHAR">
                </control>
            </title_controls>
    
            <controls>
                <control name="labelfirstname" type="TEXT" x="2" y="3" width="30" height="8" 
                        appearance_name="black" data_type="VARCHAR" default_value="First Name"/>
                <control name="editfirstname" type="EDIT" x="35" y="2" width="50" height="8" 
                        appearance_name="edit_box" data_type="VARCHAR" field_name="firstname" 
                        default_value="" size="80"/>
                <control name="labellastname" type="TEXT" x="2" y="12" width="30" height="8"
                        appearance_name="black" data_type="VARCHAR" default_value="Last Name"/>
                <control name="editlastname" type="EDIT" x="35" y="12" width="50" height="8" 
                        appearance_name="edit_box" data_type="VARCHAR" field_name="lastname" 
                        default_value="" size="80"/>
                <control name="labelemail" type="TEXT" x="2" y="22" width="30" height="8" 
                        appearance_name="black" data_type="VARCHAR" default_value="Email"/>
                <control name="editemail" type="TEXT" x="35" y="22" width="50" height="8" 
                        appearance_name="black" data_type="VARCHAR" field_name="email" 
                        default_value="" size="80"/>
                <control name="labelzip" type="TEXT" x="2" y="32" width="30" height="8" 
                        appearance_name="black" data_type="VARCHAR" default_value="Zip Code"/>
                <control name="editzipcode" type="EDIT" x="35" y="32" width="50" height="8" 
                        appearance_name="edit_box" word_wrap="0" data_type="VARCHAR" field_name="zipcode" default_value="" size="80"/>
            </controls>
        </screen>
    </screens>
    

1 个答案:

答案 0 :(得分:0)

您可以使用属性“keyboard_type”为每个编辑字段设置键盘类型。

  • 对于控件“editfirstname”和“editlastname”,添加属性keyboard_type =“CAP_WORDS”。这将使每个作品的第一个字母大写。

    <control name="editfirstname" type="EDIT" x="35" y="2" width="50" height="8" appearance_name="edit_box" data_type="VARCHAR" field_name="firstname" default_value="" size="80" keyboard_type=”CAP_WORDS”/>
    <control name="editlastname" type="EDIT" x="35" y="12" width="50" height="8" appearance_name="edit_box" data_type="VARCHAR" field_name="lastname" default_value="" size="80" keyboard_type=”CAP_WORDS”/ >
    
  • 对于控件“editemail”,添加属性keyboard_type =“EMAIL_ADDRESS”。这将使符号“@”和“.com”出现在键盘上

     <control name="editemail" type="TEXT" x="35" y="22" width="50" height="8" appearance_name="black" data_type="VARCHAR" field_name="email" default_value="" size="80" keyboard_type=”EMAIL_ADDRESS”/>
    
  • 对于控件“editzipcode”,添加属性keyboard_type =“NUMBER”。键盘只显示数字和字符' - ','/'

    <control name="editzipcode" type="EDIT" x="35" y="32" width="50" height="8" appearance_name="edit_box" word_wrap="0" data_type="VARCHAR" field_name="zipcode" default_value="" size="80" keyboard_type=”NUMBER”/>
    

您可以阅读有关keyboard_type here的更多信息。