Suppose I have a Table layout and i have a button called 'add people' which dynamically adds a row with two EdiTexts in it each time I click it. now there is another button which is supposed to save the first editText values in database and Add(sum) all the values of second editText .in HTML is very straight forward I can simply add class attribute to both inputs and loop through each class name. but I have no idea how i am supposed to do it in android.
Asked
Active
Viewed 50 times
0
-
Suppose you have some code to show... – Phantômaxx May 15 '19 at 14:34
-
1use a recyclerview – coroutineDispatcher May 15 '19 at 14:49
2 Answers
1
What about saving the references in two lists? Then you can simply iterate over the lists to either store the values in a db or to sum them.

bachph
- 153
- 1
- 12
0
original answer check
public void init(){
TableLayout tablelayout = (TableLayout) findViewById(R.id.displayLinear);
for (int i = 0; i <2; i++) {
//Dynamic Button
Button myButton = new Button(this);
myButton.setText("Push Me");
LinearLayout ll = (LinearLayout)findViewById(R.id.buttonlayout);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT);
ll.addView(myButton, lp);
}
}

Chanaka Weerasinghe
- 5,404
- 2
- 26
- 39