Liam W
Liam W

Reputation: 1163

Add a view layout to a new tab?

In my app, I allow the user to create new tabs. The tab creates fine, but I do not know how I would be able to add an already created layout to that new tab.

I have tried setContent(R.layout.layout_browse) but that causes a force close, as does adding a view to the factory and returning it.

So, how can I do what I am after?

Upvotes: 0

Views: 143

Answers (1)

wtsang02
wtsang02

Reputation: 18873

Use LayoutInflater

  View view = LayoutInflater.from(getBaseContext()).inflate(R.layout.yourxmllayout,
                    null);
            parent.addView(view );

Upvotes: 1

Related Questions