0

I have a button that when pressed, is supposed to create a new editText inside a recyclerView. And this should be repeatable until a set limit. Ex. 5 EditTexts.

I have tried this code below, but when the button is pressed, the app just crashes.

// add is the btn id
    add.setOnClickListener {
        val newText = EditText(this)
        //recyclerView is Recycler View in activity_main
        recyclerView.addView(newText)
    }

How could I go about this?

Shagufta
  • 40
  • 5

1 Answers1

0

You only need update the data and refresh the adapter.

Review this post.

Update RecyclerView

Erick Dávila
  • 347
  • 5
  • 9