0

I have a layout that as inside of it a LinearLayout that will receive a bunch of dynamic EditText, but the problem is that the AutoCompleteTextView next button doesn't go to the next EditText that is inside of the LinearLayout.

This is the XML

<TabHost
    android:id="@+id/DocumentTabHost"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_marginBottom="4dp"
    android:layout_marginTop="2dp"
    app:layout_constraintBottom_toTopOf="@+id/DocumentBTNFinalize"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/DocumentTab1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/textView4"
                        android:layout_width="203dp"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="15dp"
                        android:layout_weight="1"
                        android:text="@string/general_indentify" />

                    <AutoCompleteTextView
                        android:id="@+id/DocumentAutoIdentifier"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentTop="true"
                        android:layout_marginTop="15dp"
                        android:layout_toStartOf="@+id/DocumentSearchIden"
                        android:layout_weight="1"
                        android:singleLine="true"
                        android:focusable="true"
                        android:focusableInTouchMode="true" />

                    <ImageButton
                        android:id="@+id/DocumentSearchIden"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginTop="15dp"
                        app:srcCompat="?android:attr/actionModeWebSearchDrawable" />

                    <LinearLayout
                        android:id="@+id/DocumentTab1DynamicLayout"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_marginTop="55dp"
                        android:orientation="vertical">

                    </LinearLayout>
                </RelativeLayout>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/DocumentTab2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <RelativeLayout
                    android:id="@+id/DocumentTab2Relative"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                </RelativeLayout>

            </LinearLayout>

        </FrameLayout>
    </LinearLayout>
</TabHost>

And this is the part of the code that I have the focus for the EditText

tempText = new DocEditText(Documents.this);
if (firstButton)
{
    _autoComplete.setNextFocusDownId(tempText.getId());
    firstButton = false;
}
if (TextUtils.equals(GlobalVars.GeneralConfig.get("editTextType"), "1"))
{
    tempText.setRawInputType(Configuration.KEYBOARD_QWERTY);
}
tempText.setSingleLine();
tempText.setSQLCampName(idCampo[1]);
tempText.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
tempText.setTypeOfEditText(1);
_cabEditText.add(tempText);
tempLayout.addView(tempText);

The _autocomplete is my AutoCompleteTextView and by setting the setNextFocusDownId(tempText.getId()); should not work ? So when I press next on the soft keyboard to go to it?

Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49
Camadas
  • 509
  • 1
  • 5
  • 21

1 Answers1

0

Well after some time I did pick on this part of the code and was searching and found another solution for this in StackOverFlow link

Here is the solution for it

if (firstButton)
{
    _autoComplete.setOnEditorActionListener(new TextView.OnEditorActionListener()
    {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
        {
            if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_NEXT)
            {
                tempText.requestFocus();
            }
            return false;
        }
    });
    firstButton = false;
}

So basicly when the enter or next button is pressed on the keyboard it will request focus for the next EditText/AutoCompleteTextView that was created dynamicly

Camadas
  • 509
  • 1
  • 5
  • 21