Thursday, 15 April 2010

android - Fragments, How to overlay Fragment layout to an existing Layout XML and vice-a-versa? -


In my app, an activity with layout xml (the first page) blows on the form of the method, on some event (like button click) , I want to use the fragment class through the pieces as a container on the layout XML above and inflate the layout XML. Like below, my layout is XML (first page).

  & lt; Frame layout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: tools = "http://schemas.android.com/tools" Android: id = "@ + ID / container "Android: layout_width =" match_parent "Android: layout_height =" match_parent "& gt; & Lt; button .... & Gt; & Lt; / FrameLayout & gt; Click the  

button, I want to use the piece within the same layout container. So I use the code below the activity (on the button click).

  Fragment Manager fManager = getFragmentManager (); Fragment Transaction eTransaction = FMnager. BBT transactions (); MyFragment frag = New MyFragment (); FTransaction.replace (R.id.container, frag); FTransaction.commit ();  

Now, the new layout is visible through the piece but the old layout is also in the background and visible.

I do not want to first to use pieces from layout, as I am doing. I want to make a layout xml first, then on some event, use piece layout, and again, by piece, I want to switch to layout xml, it means vice-a-versa.

Like,

  from layout xml footage to setContentView () - & gt; Layout through pieces - & gt; Layout XML sets flows through contentview ()  

How to hide pseudo layout XML (the first page), when the slice layout increases and vice-versa is opposite?

If the piece covers the whole screen, you can set the background of the piece to a solid color Are there. / P>


No comments:

Post a Comment