Unable to add multiple textviews into linearLayout within a loop
- by Adam
for(int i=0;i<object.size();i++){
FeaturedSingleEvent event = (FeaturedSingleEvent) object.get(i);
images.add(event.getImage());
LinearLayout info = new LinearLayout(this);
info.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
TextView title = new TextView(this);
title.setText(event.getTitle());
title.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
info.addView(title);
TextView by = new TextView(this);
by.setText(event.getBy() + " " + event.getBy_name());
by.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
info.addView(by);
TextView summary = new TextView(this);
summary.setText(event.getSummary());
summary.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
info.addView(summary);
layout.addView(info);
if(i == 0){
info.setVisibility(View.VISIBLE);
}else{
info.setVisibility(View.GONE);
}
}
I'm attempting to have multiple LinearLayouts, only one being visible at a time, to create a slideshow. In a for loop, I create the layouts with their textViews, and set only the first one to be visible.
The problem is that only one TextView seems to be displaying, ie. if everything but summary is deleted, then summary will display. As of right now, only title will display, because i'm assuming it's the first one.
I'm most likely doing it wrong, so any help would be appreciated.