机器人 - 文本输入型的人的名字不工作 [英] android - text input type person name isn't working

查看:153
本文介绍了机器人 - 文本输入型的人的名字不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid项目,我想类型PersonName的一个文本框,其中默认Caps Lock键激活,但是,这code是行不通的。

 <的EditText
    机器人:ID =@ + ID / txt_user_name
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:EMS =10
    机器人:inputType =textPersonName>

    <不是requestFocus />
< /的EditText>
 

为什么会这样不起作用怎么​​办?

编辑:这里是XML code,以显示该文件是什么

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:方向=垂直>

    <的TextView
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_gravity =中心
        机器人:文本=@字符串/ t_registration
        机器人:TEXTSIZE =25dp
        机器人:TEXTSTYLE =黑体
        机器人:paddingTop =7DP
        机器人:paddingBottom会=7DP/>


    < TableLayout
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:方向=垂直
        机器人:stretchColumns =1>
        <的TableRow
            机器人:ID =@ + ID / tableRow0
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT>

            <的TextView
                机器人:ID =@ + ID / lbl_user_name
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =0.0
                机器人:文本=用户名*:/>


            <的EditText
                机器人:ID =@ + ID / txt_user_name
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:EMS =10
                机器人:inputType =textPersonName>

                <不是requestFocus />
            < /的EditText>



        < /的TableRow>
        <的TableRow
            机器人:ID =@ + ID / tableRow1
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT>

            <的TextView
                机器人:ID =@ + ID / lbl_first_name
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =0.0
                机器人:文本=名字*:/>

            <的EditText
                机器人:ID =@ + ID / txt_first_name
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@机器人:可绘制/ editbox_background
                机器人:inputType =textPersonName>
            < /的EditText>
        < /的TableRow>

        <的TableRow
            机器人:ID =@ + ID / tableRow2
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT>

            <的TextView
                机器人:ID =@ + ID / lbl_last_name
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =0.0
                机器人:文本=姓*:/>

            <的EditText
                机器人:ID =@ + ID / txt_last_name
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@机器人:可绘制/ editbox_background
                机器人:inputType =textPersonName>
            < /的EditText>
        < /的TableRow>

        <的TableRow
            机器人:ID =@ + ID / tableRow3
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT>

            <的TextView
                机器人:ID =@ + ID / lbl_email_address
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =0.0
                机器人:文本=电子邮件地址:/>

            <的EditText
                机器人:ID =@ + ID / txt_email_address
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@机器人:可绘制/ editbox_background
                机器人:inputType =textEmailAddress>

            < /的EditText>
        < /的TableRow>

        <的TableRow
            机器人:ID =@ + ID / tableRow4
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT>

            <的TextView
                机器人:ID =@ + ID / lbl_school_id
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =0.0
                机器人:文本=school_id *:/>

            <的EditText
                机器人:ID =@ + ID / txt_school_id
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@机器人:可绘制/ editbox_background
                机器人:inputType =文本>
            < /的EditText>
        < /的TableRow>

        <的TableRow
            机器人:ID =@ + ID / tableRow5
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =WRAP_CONTENT>

            <的TextView
                机器人:ID =@ + ID / lbl_password
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =0.0
                机器人:文本=密码*:/>

            <的EditText
                机器人:ID =@ + ID / txt_password
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@机器人:可绘制/ editbox_background
                机器人:inputType =textPassword>

            < /的EditText>
        < /的TableRow>

        <的TableRow
            机器人:ID =@ + ID / tableRow6
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT>

            <的TextView
                机器人:ID =@ + ID / lbl_confirm_password
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_weight =0.0
                机器人:文本=确认密码*:/>

            <的EditText
                机器人:ID =@ + ID / txt_password2
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:背景=@机器人:可绘制/ editbox_background
                机器人:inputType =textPassword>中
            < /的EditText>
        < /的TableRow>

        <的TableRow
            机器人:ID =@ + ID / tableRow7
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT>

            <的TextView
                机器人:ID =@ + ID / lbl_image_select
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_gravity =center_vertical
                机器人:layout_weight =0.0
                机器人:文本=图像选择*:/>

            <按钮
                机器人:ID =@ + ID / b_image_browse
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_gravity =center_vertical
                机器人:layout_margin =1DP
                机器人:填充=10dp
                机器人:文本=@字符串/ b_image_browse
                机器人:TEXTSIZE =15dp
                机器人:的onClick =b_image_browse_action/>

        < /的TableRow>

    < / TableLayout>

    <的EditText
        机器人:ID =@ + ID / txt_image_name
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:EMS =10
        机器人:提示=映像文件的路径
        机器人:inputType =文本>
    < /的EditText>


    < RelativeLayout的
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
         >


       <按钮
           机器人:ID =@ + ID / b_reg_Cancel
           机器人:layout_width =WRAP_CONTENT
           机器人:layout_height =WRAP_CONTENT
           机器人:layout_alignParentLeft =真
           机器人:layout_alignParentTop =真
           机器人:layout_margin =10dp
           机器人:layout_marginLeft =30dp
           机器人:填充=10dp
           机器人:文本=@字符串/ b_reg_Cancel
           机器人:TEXTSIZE =15dp
           机器人:的onClick =b_reg_Cancel_action/>

        <按钮
            机器人:ID =@ + ID / b_reg_Submit
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignParentRight =真
            机器人:layout_alignParentTop =真
            机器人:layout_margin =10dp
            机器人:layout_marginRight =100dp
            机器人:填充=10dp
            机器人:文本=@字符串/ b_reg_Submit
            机器人:TEXTSIZE =15dp
            机器人:的onClick =b_reg_Submit_action/>

    < / RelativeLayout的>



< / LinearLayout中>
 

解决方案

如果你试图显示人名正常,试试这个:机器人:利用=改为 。如果要全部大写,您可以更改字符或做类似LuxuryMode说!

编辑:

您应该删除安卓inputType =textPersonName字段。它将工作!

In my android project I want a textfield of type personname where by default caps lock is activated, however, this code isn't working.

<EditText
    android:id="@+id/txt_user_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textPersonName" >

    <requestFocus />
</EditText>

Why might this not work?

EDIT: here is the xml code to show what the file is

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="@string/t_registration"
        android:textSize="25dp"
        android:textStyle="bold"
        android:paddingTop="7dp" 
        android:paddingBottom="7dp"/>


    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:stretchColumns="1" >
        <TableRow
            android:id="@+id/tableRow0"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/lbl_user_name"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.0"
                android:text="User Name * :   " />


            <EditText
                android:id="@+id/txt_user_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:inputType="textPersonName" >

                <requestFocus />
            </EditText>



        </TableRow>
        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/lbl_first_name"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.0"
                android:text="First Name * :   " />

            <EditText
                android:id="@+id/txt_first_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@android:drawable/editbox_background"
                android:inputType="textPersonName" >
            </EditText>
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/lbl_last_name"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.0"
                android:text="Last Name * :   " />

            <EditText
                android:id="@+id/txt_last_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@android:drawable/editbox_background"
                android:inputType="textPersonName" >
            </EditText>
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/lbl_email_address"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.0"
                android:text="Email Address:   " />

            <EditText
                android:id="@+id/txt_email_address"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@android:drawable/editbox_background"
                android:inputType="textEmailAddress" >

            </EditText>
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/lbl_school_id"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.0"
                android:text="school_id * :   " />

            <EditText
                android:id="@+id/txt_school_id"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@android:drawable/editbox_background"
                android:inputType="text" >
            </EditText>
        </TableRow>

        <TableRow
            android:id="@+id/tableRow5"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/lbl_password"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.0"
                android:text="Password * :   " />

            <EditText
                android:id="@+id/txt_password"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@android:drawable/editbox_background"
                android:inputType="textPassword" >

            </EditText>
        </TableRow>

        <TableRow
            android:id="@+id/tableRow6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/lbl_confirm_password"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.0"
                android:text="Confirm password * :   " />

            <EditText
                android:id="@+id/txt_password2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@android:drawable/editbox_background"
                android:inputType="textPassword" >"
            </EditText>
        </TableRow>

        <TableRow
            android:id="@+id/tableRow7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/lbl_image_select"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_weight="0.0"
                android:text="Image Select * :   " />

            <Button
                android:id="@+id/b_image_browse"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_margin="1dp"
                android:padding="10dp"
                android:text="@string/b_image_browse"
                android:textSize="15dp"
                android:onClick="b_image_browse_action" />

        </TableRow>           

    </TableLayout>

    <EditText
        android:id="@+id/txt_image_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:ems="10" 
        android:hint="Image File Path"
        android:inputType="text" >
    </EditText>


    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         >


       <Button
           android:id="@+id/b_reg_Cancel"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_alignParentLeft="true"
           android:layout_alignParentTop="true"
           android:layout_margin="10dp"
           android:layout_marginLeft="30dp"
           android:padding="10dp"
           android:text="@string/b_reg_Cancel"
           android:textSize="15dp"
           android:onClick="b_reg_Cancel_action" />

        <Button
            android:id="@+id/b_reg_Submit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_margin="10dp"
            android:layout_marginRight="100dp"
            android:padding="10dp"
            android:text="@string/b_reg_Submit"
            android:textSize="15dp" 
            android:onClick="b_reg_Submit_action"/>

    </RelativeLayout>



</LinearLayout>

解决方案

If you try to display person name as normal, try this: android:capitalize="words". If you want to all caps you can change words into characters or doing like Mr. LuxuryMode said!

Edited:

You should remove android:inputType="textPersonName" field. It will work!

这篇关于机器人 - 文本输入型的人的名字不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆