set TextView value for array
I have make an application where I am swiping number of photos,I have
added these photos in an array and I want to get the simple numerical
values(for example:-1,2,3 etc) for these items and for this I have used
the for loop,and set these values to the textview and then dynamically
adding these textview to the linearlayout and and then this linearlayout
to the viewgroup container. By doing this I am just able to show the last
number value for an array item;below is my code.
LinearLayout linearlay=new LinearLayout(context);
linearlay.setOrientation(LinearLayout.VERTICAL);
imageView.setImageResource(image_id[position]);
linearlay.addView(imageView,0);
for(int i=0;i<image_id.length;i++)
{
linearlay.removeView(textView);
textView.setText("Image: "+(i+1));
linearlay.addView(textView);
((ViewPager) container).addView(linearlay);
}
return linearlay;
} TextView textView=new TextView(context);
I want to setText value as 1,2,3... and show it in layout but only the
last value is being shown.
No comments:
Post a Comment