1

Is there any way to Create a card on a click of a button Android?

normal state of the app

then when I click the add button it will generate another card similar to the first one

after clicking the add button

Boken
  • 4,825
  • 10
  • 32
  • 42
Exor
  • 31
  • 6
  • 1
    have your tried any code? – Ninja Mar 19 '19 at 10:10
  • I like @ronginat 's answer. But if you're not using a recyclerview, you can add a new view to your layout. Check this: https://stackoverflow.com/questions/38012381/duplicate-a-view-programmatically-from-an-already-existing-view – uan Mar 19 '19 at 10:37
  • Please do not tag with `Android-studio` just because you use it. This tag is for question about the IDE itself – vincrichaud Mar 19 '19 at 11:01

1 Answers1

0

You can use A RecyclerView with RecyclerView.Adapter and some sort of List of elements.
When you want to create a new card, simply add an element to the end of your list and call notifyItemInserted(position).
Some reference

Also, you can use a vertical LinearLayout to hold your views and Create a xml file to represent your cards. Every time you want to add a new view, inflate the xml file and type layout.addView(view)
It will be more complicate to manage your cards, but if you plan only to add new cards it may be simpler than a recyclerview.
Example

These are the best ways i know to achieve what you asked.

ronginat
  • 1,910
  • 1
  • 12
  • 23