2014-03-27 151 views
0

达到最大字符我有这样的EditText新活动:安卓:当EditText上

<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

如果达到了最大的字符数量,可以使用Textwatcher在textchange之后确定。

试试这个代码:

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

请尽量提供您的答案,解释和/或链接。 SO上通常只有代码“答案”。解释帮助他人学习更多东西。 – codeMagic

+0

谢谢生病试试吧! –

+0

它完美的感谢! –