0

I'm facing this situation. I have a recycler view of cardviews. In each row I just have a Textview and an EditText. I'd like to : * focusing on the first edittext of the first row, pushing on the "next" button on the soft key which appears, the focus will go in the same edittext on the next row. Is this possible?

I know android:nextFocusForward="@+id/.." but I have no id (because of course it's the same of the current edittext).

I hope I was clear and you can help me with this problem.

Just to be clear, this is my edittext in the cardview :

       <EditText
        android:id="@+id/prezzo_inserireprezzo"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/nomeprodotto_inserimentoprezzo"
        android:layout_alignParentEnd="true"
        android:layout_marginEnd="15dp"
        android:ems="10"
        android:inputType="numberDecimal"
        android:maxLines="1"
        android:text="56.13"
         />
ozzem
  • 294
  • 1
  • 3
  • 16

1 Answers1

0

If you're building your CardViews programmatically then you're going to have to cycle through all your views (expensive) or keep a reference to every edit text you create so that you can request focus on what you determine to be the next one. There is no way to do this in xml unless your entire layout is hard coded.

You can keep a reference to each edit text you create in an array list.

List<EditText> myEditTexts = new ArrayList<EditText>();

You can reference this post for more information on handling return events Android - Handle "Enter" in an EditText

anomeric
  • 688
  • 5
  • 17