0

whenever i set rowTextView.setText(" row value #" + str); then arraylist last value showing there . My listdata are 60,65,70,75,80 . only last value showing there .I want all data .How can i achive this ????

 int size = al_getAllProductSize.size(); System.out.println("The size of array is: " + size); for (int i = 0; i < size; i++) { } final int N = 5; // total number of textviews to add final TextView[] myTextViews = new TextView[N]; // create an empty array; for (int i = 0; i < N; i++) { final TextView rowTextView = new TextView(MainActivity.this); for (String str : al_getAllProductSize) { rowTextView.setText(" row value #" + str); // i want all value through loop } ll_textViewObj.addView(rowTextView); // save a reference to the textview for later myTextViews[i] = rowTextView; } 
4
  • 1
    Do you want to add all the ArrayList data into a single textview? Commented Aug 26, 2016 at 6:30
  • @Dentor for good approach different textview.5 datas for 5 textview Commented Aug 26, 2016 at 6:32
  • @Dentor Single textview possible ?? Commented Aug 26, 2016 at 6:34
  • you could concat the arrayList values into a string and then set that string value to textView. Commented Aug 26, 2016 at 6:35

3 Answers 3

1

If you want each string in each textview, you can use something like:

for (int i = 0; i < N; i++) { final TextView rowTextView = new TextView(MainActivity.this); // getting respective string val from list rowTextView.setText(" row value #" + al_getAllProductSize.get(i)); ll_textViewObj.addView(rowTextView); // save a reference to the textview for later myTextViews[i] = rowTextView; } 
Sign up to request clarification or add additional context in comments.

Comments

1

Try this one . hope it will help you.

final int X = 5; // total number of textviews to add final TextView[] myTextViews = new TextView[X]; // create an empty array; for (int i = 0; i < X; i++) { // create a new textview final TextView rowTextView = new TextView(this); // set value in textview rowTextView.setText("row value #" + i); // add the textview to the linearlayout ll_textViewObj.addView(rowTextView); // save a reference to the textview for later myTextViews[i] = rowTextView; } 

Comments

0

Try this

int size = al_getAllProductSize.size(); TextView[] myTextViews = new TextView[size]; for (int i = 0; i < size; i++) { myTextViews[i] = new TextView(MainActivity.this); rowTextView.setText( al_getAllProductSize.get(i)); ll_textViewObj.addView(myTextViews[i]); } 

3 Comments

both answer working .but #Shaishav first . i will upvote your answer
I have low rep. thats why unable to upvote your answer .
#al_getAllProductSize.get(i) .I forgot this

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.