Do you set the last argument of inflate() function in oncreateview() to false? On 12 Feb 2012 05:19, "coreno" <[email protected]> wrote: > > I am trying to learn Fragments, so I can eventually create a tablet- > friendly interface to my apps. I'm mostly just experimenting/learning > now, but I can't seem to get things working. > > I just want the typical two-pane layout, but most of the examples I > have found show the left pane as a ListFragment (and the right pane > shows the details relating to the selection on the left). > > I could go with a ListFragment, but for learning and experimentation > purposes, I just wanted a regular Fragment, that loads a LinearLayout > XML file for its View. I have a button in the View that when clicked, > is supposed to add a Fragment to the right pane, which is defined as a > FrameLayout in the XML file (I've also tried a regular Fragment). > > The problem is, I'm getting this error when the button is clicked: > java.lang.IllegalStateException: The specified child already has a > parent. You must call removeView() on the child's parent first. > > I've tried different combinations and scenarios, such as doing the > FragmentTransaction in onCreateActivity instead of onCreateView, or > removing the button press and just having it execute the transaction > when my Fragment loads. > > I don't know what I'm doing wrong, any pointers in the right direction > would be greatly appreciated. > > Code: > Launcher Activity: http://pastebin.com/11RyWbLb > Left "Selector" Fragment: http://pastebin.com/yiGhPLnh > Right "Details" Fragment: http://pastebin.com/KYmQPDNg > main.xml: http://pastebin.com/s5HqXSUk > (the other two xml's are just basic layout files, the selector > fragment has a button, details fragment just has a text view) > > *Ideally* I want the activity to open, and I just have the one > fragment visible, taking up the whole screen, until the user clicks on > a button, and the 2nd fragment comes in from the right, with the > corresponding data. But one step at a time I suppose. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > 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 post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

