Reputation: 43893
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>
Upvotes: 4
Views: 6221
Reputation: 39988
I used this for the caps words and no suggestion
android:inputType="textCapWords|textNoSuggestions"
e.g. Tom Hanks
Upvotes: 1
Reputation: 11555
Use
android:inputType="textPersonName|textCapWords"
as using only "textPersonName"
is not enough so name's first letters would be capitalized.
Similarly with postal addresses:
android:inputType="textPostalAddress|textCapSentences"
Upvotes: 16
Reputation: 8200
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!
Upvotes: 1