Thursday, April 11, 2013

Using multiple fragments and replacing/swapping with other fragments eventually, android

I found this very interesting post on stackoverflow about how to use multiple fragments and replace fragments on the go: stackoverflow.com/questions/llegalstateexception-when-replacing-a-fragment

Excerpt: While using multiple fragments don't declare them in layout (or activity which will have fragment) instead add fragment to an activity programmatically and swap/switch with other fragments by fragment transaction manager. In case you define fragment in the XML of activity then it won't allow you to switch fragments dynamically (ofcourse by Java code) because once you define any fragment in XML that fragment is like static for that activity.

Very interesting thought while designing UI of your application.

No comments:

Post a Comment