2014-03-27 3 views
0

에 도달 최대 문자 나는이 글고이 새로운 활동 :안드로이드 : 글고

<EditText 
    android:id="@+id/editTextNew" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_marginBottom="50dp" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:layout_marginTop="50dp" 
    android:padding="25dp" 
    android:maxLength="200" 
    android:gravity="top|left" 
    android:background="#fff" 
    android:lineSpacingMultiplier="1.5" 
    android:inputType="textMultiLine|textCapSentences" > 
</EditText> 

그것은, 내가 어떻게 200 개 문자의 최대 수있다 그것을 마지막 문자가 입력 된 있도록 화면 "다음 버튼"이 나타납니다.

답변

0

최대 문자 수에 도달 한 경우 텍스트 교체 후 텍스트 와치를 사용할 수 있습니다.

이 코드를보십시오 :

EditText yourEditText = (EditText)findViewById(R.id.editTextNew); 

yourEditText.addTextChangedListener(new TextWatcher() { 

     @Override 
     public void onTextChanged(CharSequence s, int start, int before, int count) {} 
     @Override 
     public void beforeTextChanged(CharSequence s, int start, int count,int after) {} 

     @Override 
     public void afterTextChanged(Editable s) { 
      if(s.length() >= 200){ 
       // Show your Button now ... 
      } 
     } 
    }); 
+2

당신의 답변에 대한 설명 및/또는 링크를 제공하여보십시오. Code-only "answers"는 일반적으로 SO에 대해 싫어합니다. 설명은 다른 사람들이 훨씬 더 많이 배울 수 있도록 도와줍니다. – codeMagic

+0

고마워! –

+0

그것은 완벽한 감사를 작동합니다! –