2016-08-01 1 views
1

안녕하세요. 내 edittext에 문제가 있습니다. 내가 자동차에 원하는 글고 치기의 첫 글자를 대문자로하지만, 일이되지 않습니다Edittext 첫 글자가 자동 ​​대문자가 아님

<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의 XML

은 아래에 붙여 넣습니다. 도와주세요 !

참고 : 여러 줄 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" /> 
관련 문제