Reputation: 495
In my database I have the following table:
|----------- Product -----------|
| id | name | description | qtd |
| 1 | A | Product A | |
| 2 | BB | Product B | |
| 3 | CCC | Product C | |
| 4 | DDDD | Product D | |
I wanted the "Ativade" show beyond information, 1 input and 1 button.
|-------------|
| A |
| Product A |
| ____ |
| Qtd |____| |
| |
| | NEXT | |
| |
|-------------|
After the user enters the amount, and click "Next". Was going to appear the product B:
|-------------|
| BB |
| Product B |
| ____ |
| Qtd |____| |
| |
| | NEXT | |
| |
|-------------|
And after the last product, the input data would be updated in the field "Qtd" in the table "Product".
How can I do this, given that the number of products is not always the same, and that this information comes from an external database rather than SQLite?
Upvotes: 0
Views: 289
Reputation: 1532
Assuming you have fetched everything you need from the database.
One way of doing this could be:
You start by storing all the data in an Array of Map's
ArrayList< Map< String, String >> list;
So you now have something like this:
list[x] = {"name" => NAME_x, "description" => DESCRIPTION_x, "qtd" => QTD_x}
...
private int position = 0;
list[position]
into the layout's views(next)
. Each time the button is pressed to get the value from the EditText
field and assign it to list[position]["qtd"]
. Then you increment position
and call (M) method. (Don't forget to check if you have reached the end of your ArrayList before calling (M), and then do whatever you want with the data you got).Hope this helps
Upvotes: 1