Thursday, July 4, 2013

[android-developers] Re: Trying to use fragment with multiple layouts - a use case and a question

these layouts sound simple enough for you to just put in one layout and just show/hide the appropriate parts.
Also, these layouts sound so close to one another, you can just change the text on the labels\buttons and change their onClickListeners and thats it.

On Thursday, July 4, 2013 12:30:52 PM UTC+3, shushu wrote:
Hi all,

I have an app that work with a backend.
I want to add to multiple activities in it a small user UI, which shows a nice "Hello guest" + login button, or a "Hello <user>" + logout.

It was clear to me that I should do it with a fragment, and it is also clear to me that I don't want one layout for both cases.
Instead, I want two separated layouts, and to load the right layout according to user state.

The problem is - after showing the "guest" layout and nicely log-in in a background thread, the fragment's broadcast receiver gets the knowledge the user was logged in, but I fail to find a way to simply replace the layout of the fragment.

At first creation, the method "public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)" is called, and the returned view has the inflated layout needed.
Keeping this returned View and updating its values does not effect anything.
Even saving the container (regardless the other problem, which is the fact that if the fragment was created from XML this container will be null) and inflating into it does not work.

I know I can use different fragments (one for guest and one for logged-in user) and change between them in the activity, but this is not my goal, and it is not modular enough.

Any ideas ?
Any suggestions ?

Thanks !
Shushu Inbar
Mobile4Social.com

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate