Make next EditText appear on screen when action next clicked

how to automatically move to the next edit text in android
how to change the focus to next edit text in android
how to focus next edittext in android
android move cursor to next edittext
how to set cursor focus on edittext in android
android edittext imeoptions not working
how to change focus from one edittext to another in android
android set next focus programmatically

I have several EditTexts on my screen and they are all built in the following way.

XML:

<android.support.design.widget.TextInputEditText
            android:id="@+id/textInputEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/name"
            app:fontFamily="@font/karla"
            android:inputType="textMultiLine|textCapCharacters"
            android:maxLength="12"
            android:textColor="#5C7264"
            />

Code:

private void addItemsToLinearLayout(int numItems) {

 LayoutInflater inflater = LayoutInflater.from(mContext);

     for (int i = 0; i < numItems; i++) {

         View childView = inflater.inflate(R.layout.item_linearlayout, null);        

         linearlayoutPlayersNames.addView(childView);            

         ImageView deleteRowIcon = childView.findViewById(R.id.deleteRowIcon);     
         deleteRowIcon.setOnClickListener(this);

         TextView myTV = childView.findViewById(R.id.txtTitle);          
         myTV.setText(String.format(getString(R.string.player), linearlayoutPlayersNames.indexOfChild(childView) + 1));         


         EditText editText = childView.findViewById(R.id.textInputEditText);
         editText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
         editText.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);

    }
}

When I click the next button of the soft keyboard it moves to the next EditText as expected, BUT ONLY if the next EditText is visible on screen. When the next EditText is not visible on screen the action next has no effect and, on top of that, it changes the next action button to a carriage return action button as shown in this video: https://imgur.com/a/snAbdmU

What I intend to do is to click the next button and move the visibility to the next EditText.

UPDATE: some of you have told me to do this using android:nextFocusDown or programmatically with editText.setNextFocusForwardId(editTextSecond.getId()); but I can't because I use a loop to create the EditTexts as shown now in the code.

Do this :

  EditText editText2 = childView.findViewById(R.id.textInputEditText);
  EditText editText = childView.findViewById(R.id.textInputEditText);
  editText.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_DONE) {
        editText2.setVisibility(View.VISIBLE);
        editText2.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        editText2.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
              return handled;
             }
        }
    });

  editText2.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_DONE) {
               // do same for others to    
            return handled;  
             }

        }
    });

Move to another EditText when Soft Keyboard Next is clicked on , the action key performs a "next" operation, taking the user to the next field that will if you do not want every time it adds, create style: add style in values/style.xml use inputType for every edittext and the next button will appear in keyboard. The only way to focus EditText No 8 is to hide the keyboard, scroll down and click EditText No 8. You can scroll up without hiding the keyboard. If you set android:windowSoftInputMode="adjustResize", the top portion of the activity (Toolbar/Appbar) is maintained with EditText pushed to above the keyboard.

Yes, You need to remove textMultiLine from android:inputType then it will work with both the cases next EditText is visible and not visible.

<android.support.design.widget.TextInputEditText
        android:id="@+id/textInputEditText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/name"
        app:fontFamily="@font/karla"
        android:inputType="textCapCharacters"
        android:maxLength="12"
        android:textColor="#5C7264"
        />

Get Value from the EditText and Set value to the TextView, from the user through EditText view in Android and display it in the TextView. what action to perform next or what to do with the data received from user etc. is used to define the action to be performed when a button is clicked in the app. to get the view instance in Java, that you have made and used in layout XML. Now we need to create a custom OnEditorActionListener for the target EditText that will recognize when the ‘DONE’ button has been clicked. In it we override the onEditorAction() method, get an instance of the InputMethodManager, and use it to close the soft keyboard.

As you mentioned that you are doing it programmatically than in instead in xml using

android:nextFocusDown="@id/textInputEditTextSecond"

You can use it programmatically like this

editText.setNextFocusForwardId(editTextSecond.getId());

and add editText.setImeOptions(EditorInfo.IME_ACTION_NEXT); for all EditText

Inside for loop setId of each EditText and then set nextForward as below

private void addItemsToLinearLayout(int numItems) {

 LayoutInflater inflater = LayoutInflater.from(mContext);

     for (int i = 0; i < numItems; i++) {

         View childView = inflater.inflate(R.layout.item_linearlayout, null);        

         linearlayoutPlayersNames.addView(childView);            

         ImageView deleteRowIcon = childView.findViewById(R.id.deleteRowIcon);     
         deleteRowIcon.setOnClickListener(this);

         TextView myTV = childView.findViewById(R.id.txtTitle);          
         myTV.setText(String.format(getString(R.string.player), linearlayoutPlayersNames.indexOfChild(childView) + 1));         


         EditText editText = childView.findViewById(R.id.textInputEditText);
         editText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
         editText.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);

         // setId of each EditText and then set nextForward as
         editText.setId(i);
         editText.setNextFocusForwardId(i+1);

    }
}

Working with the EditText, textVisiblePassword, Text, next button, and no microphone input Check out the basic event listeners cliffnotes for a look at how to listen for changes to an EditText and perform an action when those the TextInputLayout can be used to setup a floating label to display hints and Make sure you have the app namespace� Yep! you have to call setContentView (id) first. So that the system can display the screen contents, and then you point out the EditText which will probably exist in your screen contents. Otherwise it will show an exception with Force Close dialog. – Adil Soomro Mar 15 '11 at 6:57

EditText, Action � Notification. When you define an edit text widget, you must specify the R.styleable. that is shown, acceptable characters, and appearance of the edit text. changes are made, or validate the format of user input, for example. android:nextClusterForward, Defines the next keyboard navigation� Some apps have a EditText (textbox) which, when you touch it and it brings up the on-screen keyboard, the keyboard has a "Search" button instead of an enter key. I want to implement this. How can I implement that Search button and detect press of the Search button?

Android - EditText Control, Next Page. A EditText is an overlay over TextView that configures itself to be editable. It is the predefined subclass of TextView that includes rich editing� 3. Android ListView with EditText Example. Android Listview Edittext With TextView Tutorial Example is today’s topic. We will implement Custom Listview with EditText and will set and get text values of all edittext in all child elements of listview. Many developers have oftern several problems regarding this topic like:

Android Quick Tip: EditText with DONE Button That Closes the , Android Quick Tip Close the keyboard when you click 'DONE'… to create a custom OnEditorActionListener for the target EditText that will� Kotlin setOnClickListener for Button Android button is a UI element generally used to receive user actions as input. In this tutorial, we shall learn to set OnClickListener for button. A quick look into code What we have done here is, we got the reference to the Button and then used setOnClickListener method to trigger an action when the button is clicked. Now we shall look into the layout xml

Comments
  • have you tried in your xml android:imeOptions="actionNext" ?
  • @AntonisRadz As you can see, it is set programmatically. The misbehavior comes into place when the next EditText is not visible on screen.
  • Is there no other solution @AbidKhan ? I generate the EditTexts programmatically depending on the amount of players that want to play so it isn't easy for me to do this.
  • check using the edittext.setSingleLine(true); or edittext.setMaxLines(1);
  • Check it in my answer then.
  • I want to use textMultiLine... And even doing so it doesn't fix the problem.
  • I appreciate your help, but my case is a bit more complicated as my update of the question shows.
  • Thank you once again, but it doesn't work in my case either... I guess for someone else it may be helpful but not for me. I have a more complex layout where, once the user has chosen the amount of players he can also remove and add more so after removing players and adding new ones these new players ids wouldn't be sequential and thus the behaviour of .setNextFocusForwardId would be unexpected.