2016-08-01 16 views
1

こんにちは私は私のedittextに問題があります。Edittextの最初の文字は自動大文字ではありません

EDITTEXTのXMLは以下の貼り付けられます:

<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" /> 

問題:私は自動車のEditTextの最初の文字を大文字にしたいが、それは起きていません。助けてください !

注:複数行のEditTextが必要です。

+0

実際にこのコードは、すべての行を大文字にしています。確認してください。大文字の行にすべての単語を入力する必要がありますか? –

+0

android:inputType = "textMultiLine | textCapWords | textCapSentences"のようなinputTypeのtextCapWordsも追加してみてください。 – mubeen

+0

私はちょうどあなたのコードをテストし、それは私のために働く。 EditTextをコードのどこかにプログラム的に変更しますか? – babadaba

答えて

-2
android:inputType="textCapSentences" 
+0

既に試してみました! –

0

大文字の文章を作成するアクティビティでこのコードを使用できます。すべての文章の最初の単語の大文字の大文字と新しい文章は、ドット(。)とスペースの後ろを意味します。

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

使用このコード

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); 
1

あなたはtextCapWordsにinputTypeのtextCapSentencesを変更したはずです。

<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" /> 
関連する問題