2

Hello I am facing a problem with my edittext.

the xml of the Edittext is pasted below :

 <EditText
                android:id="@+id/edttxt_description_taskdescription"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="@dimen/padding_large"
                android:layout_marginTop="@dimen/margin_.5x"
                android:background="@color/white"
                android:lines="2"
                android:gravity="top"
                android:hint="@string/activity_task_description_name_hint"
                android:imeOptions="actionDone"
                android:singleLine="false"
                android:inputType="textMultiLine|textCapSentences"
                android:maxLength="85"
                android:textSize="@dimen/text_16pixels" />

Issue : I want to auto capitalize the first letter of the EditText but it is not happening. Please help !

Note : I want a multiline EditText.

Vivek Bhardwaj
  • 530
  • 5
  • 16

3 Answers3

2

You should've changed the inputType textCapSentences to textCapWords.

<EditText
            android:id="@+id/edttxt_description_taskdescription"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginLeft="@dimen/padding_large"
            android:layout_marginTop="@dimen/margin_.5x"
            android:background="@color/white"
            android:lines="2"
            android:gravity="top"
            android:hint="@string/activity_task_description_name_hint"
            android:imeOptions="actionDone"
            android:singleLine="false"
            android:inputType="textMultiLine|textCapWords"
            android:maxLength="85"
            android:textSize="@dimen/text_16pixels" />
Fahry Mohammed
  • 599
  • 5
  • 18
0

you can use this code in your activity making a upper case sentence . In every sentence first word letter uppercase and new sentence means after dot(.) and space .

for example:
 i/p---> hi hello. hi hello    
  o/p---> Hi hello. Hi Hello

use this code

 EditText assignmentName=(EditText) findViewById(R.id.assignmentNameId);
     String sassignmentName = assignmentName.getText().toString();
     char[] assignment=sassignmentName.toCharArray();
                char[] assignment1=new char[assignment.length];
                int  count=0;
                for(int i=0;i<=assignment.length-1;i++)
                {
                    if(i==0 && Character.isLowerCase(assignment[i]) ) {
                        char first = assignment[i];
                        char first1 = Character.toUpperCase(first);
                        assignment1[count] = first1;
                        count++;
                    }else if(Character.isWhitespace(assignment[i-1]) &&  assignment[i-2]=='.'  && Character.isLowerCase(assignment[i]))
                    {
                        char first = assignment[i];
                        char first1 = Character.toUpperCase(first);
                        assignment1[count] = first1;
                        count++;
                    }
                    else {
                        assignment1[count]=assignment[i];
                        count++;
                    }
                }
                String UpperCaseassignmentName=String.valueOf(assignment1);
VISHWANATH N P
  • 304
  • 1
  • 7
  • 11
-2
android:inputType="textCapSentences"