0

What I have created till now is as follows:

Please see this image Purchase Screen

As shown in the image above, the screen (PurchaseActivity) initially has:
1. spinner for customer - line 1
2. fragement containing spinner for product, rate, and a delete fab - line 2
3. linear layout for displaying fragments same as above. They will be dynamically added.- line 3
4. fabAdder, adds fragment dynamically - line 4
5. save button for saving to persistent layer. line - 5

To add views dynamically, is this the right way. If so, how do I get the values out of the views inside fragment which are dynamically added in my activity.
Otherwise what is the right way of handling/providing the user with controls to add data dynamically.

Advantages of using this method:
The user will be able to add as much product as he wants, he may delete it conveniently and also editing is easy.

Please use the comments section to if you feel the question needs more content.
Answer or lead me in right path to fulfill this requirement.

-Newbie Androider

Leo
  • 43
  • 7
  • Using Fragment for the simple layout is not the correct way to add different layout in an activity, I think you must use in you activity XML, which is going to reduce lot of code and classes (like fragments etc.) – Ashutosh Srivastava Jun 01 '17 at 07:53

1 Answers1

0

You can make outside class similar to POJO for handling values from fragment simultaneously. Something like this answer of mine for some other question: https://stackoverflow.com/a/44051019/5577679

Otherwise, why don't you make good old POJO for values?

tompadre
  • 797
  • 7
  • 22