I am new to Android programming and currently trying to understand implementing simple Java in it. What I am trying to do is to understand how to add 20 textViews in Android studio. I mean, what is the best choice here. Is it:
a) Manually add 20 textViews and when I click on button A all the textViews will update with a formula. I believe this will create unnecessary java code and repetition.
b) Create a for loop, add one textView and then update automatically via a method. What I have done so far. Code underneath (immagine there is a button connected to the MainCalculate ID:
double realPrice = 10;
double total = (realPrice * 2)+1;
double increase = 0.1;
TextView percentageTextView = (TextView) findViewById(R.id.percentageTextViewID);
public void MainCalculate (View view) {
MarketValueAnswer.setText(Double.toString(marketValueAnswer));
for (double i=realPrice; i<=total; i+=increase) {
double formula = ((realPrice*increase) + realPrice);
increase+=0.05;
percentageTextView.append("\n" + formula);
}
Thanks and best regards,