3
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.

1 Answer 1

4

ah it seems I forgot to add info.setOrientation(LinearLayout.VERTICAL);

1
  • 1
    Had exactly the same problem and this was the solution!
    – Duncan
    Sep 11, 2012 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.