Streletz
Streletz

Reputation: 202

Changing the appearance of a fragment

Is it possible to change the appearance of a fragment (set a different View) during its operation or is it possible only in the onCreateView () method?

Upvotes: 1

Views: 75

Answers (2)

Streletz
Streletz

Reputation: 202

I'll answer my own question. Not to create chaos in the management of widgets. It is better to use child fragments or show/hide necessary widgets. The answer found here.

Upvotes: 0

Berťák
Berťák

Reputation: 7322

You can possibly do it this way:

  1. Return some placeholder view (e.g. FrameLayout) in your onCreateView() and keep reference to it.
  2. Then, you can add/remove other views from your placeholder view, when you need to do so.

However, I think it is not how Fragments are supposed to be used. (changing its views rapidly during runtime)

Upvotes: 2

Related Questions