SilverBlue
SilverBlue

Reputation: 269

I can't see my LinearLayout, why?

My Code:

LinearLayout rb = new LinearLayout(this);
int idy = getResources().getIdentifier("rb"+i, "Ressourcen_Reihe1", getPackageName());
rb.setBackground(normalBox);
rb.setVisibility(View.VISIBLE);
rb.addView(imgBtnItem);

I can't see the LinearLayout.
What's my mistake?

Upvotes: 0

Views: 52

Answers (2)

OneCricketeer
OneCricketeer

Reputation: 191728

You haven't added any LayoutParams to the View. Therefore, it takes up no space.

Also, you haven't shown rb being added to a parent layout.

Upvotes: 0

Michael Krause
Michael Krause

Reputation: 4849

Based on the provided code, rb has not been made part of a live view hierarchy. You'll need to add it to a ViewGroup associated with the layout for your fragment/activity somewhere for it to show up.

Upvotes: 1

Related Questions