0

I have an EditText object in one of my activities. I have implemented the code to insert a "Done" button on the keyboard, and hide it when the user's done typing. I've noticed though, that the text is not being auto-returned when it reaches the maximum length I've attached to the EditText object. In my iPhone version of this app, I've been able to set an attribute called "auto-return" for my text box that automatically returns, and this is what I would like to implement for the Android version, but I don't know how. Here is the code I've written:

    <EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:maxLength="10"
    android:hint="@string/hint"
    android:inputType="textImeMultiLine"
    android:imeOptions="actionDone"
    android:layout_marginTop="15dp"
    android:gravity="center"/>

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_type_order);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    editText1 = (EditText)findViewById(R.id.editText1);
    editText1.setLines(10);
    editText1.addTextChangedListener(new TextWatcher(){

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before,
                int count) {
            // TODO Auto-generated method stub

            InputMethodManager keyboard1 = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            keyboard1.hideSoftInputFromInputMethod(editText1.getWindowToken(), 0);


        }
    });
A--C
  • 35,565
  • 10
  • 102
  • 90
embersofadyingfire
  • 405
  • 1
  • 4
  • 16

1 Answers1

0

I'm still trying to understand... You want the keyboard to hide itself and to click "Done" once they've reached the maximum of 10 lines?

This thread and/or this should be able to help you. Also, next time please try to find a different word to use than "Auto Return" as often because its not Android lingo. Describe what the auto return function is. Luckily I know a little about iOS development :)

Community
  • 1
  • 1
  • Not exactly Collin. As the user types into the EditText, I would like for a carriage line return to occur ( like pressing enter and moving down and left to the next line ). Instead, my text is continuing on the same line, and disappearing from view. The keyboard has been altered to have a "done" button where the return key would be. When the user is done typing, they can press "done", and the keyboard will disappear from view, and reveal a button thats been blocked by the keyboard.Thanks for your help! – embersofadyingfire Feb 08 '13 at 02:39