سؤال

I have this 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>

It has a max of 200 characters, how can i make it so that when the last character has been typed, the screen fades out and a "next button" appears?

هل كانت مفيدة؟

المحلول

You can use a Textwatcher to determin after a textchange if the maximum amount of chars have been reached.

Try this code:

 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 ...
            }
        }
    });
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top