0

I want to create editText and button on my project, when click on the button it duplicate the same row. Example

My Hobby
----------
Badminton   +

When click on the + button there will be a new row generate and the new row include with - to delete this row, only the first row not - button. I need to keep the data that from the edittext and save it to my database.

My Hobby
  ----------
   Badminton   +
 - Basketball  +

Is this possible way to create? Or any suggestion to create this?

Amsheer
  • 7,046
  • 8
  • 47
  • 81
Arzozeus
  • 103
  • 2
  • 11

1 Answers1

0

Yes, fairly easily. First, create an xml file that holds the views you'd want for the row. Then in the onClick of the + key, inflate that file into a view, and add it to the parent layout. Remember to set any fields you need to like onClickListeners or view texts. On a minus click, remove the view you inflated from its parent.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • I have no idea how to do it, I found a post http://stackoverflow.com/questions/6216547/android-dynamically-add-views-into-view,but I dont know how to apply in my project, can you write a simple code to show me, thanks – Arzozeus Jun 28 '14 at 07:51