Skip to content Skip to sidebar Skip to footer

Button Open A Fragment

I need to implement Fragment in my Android app that when pressed in a button open up. But I am not sure where to place the fragment in the XML. The interaction is inside a listvi

Solution 1:

First you should create a FragmentActivity which has at least a LinearLayout And then you should create two Fragment, one with the ListView and its items, one with what you want to do with.

In your FragmentActivity you can manage thoose two Fragment transactions.

Read this Link from Android Developer Site carefully. It has all information you need.

Solution 2:

I ended up concluding that it was a very bad idea to use fragment when opening a secondary view after pressed an item in the listView.

So my solution was to use and inflate a custom view at the moment the button was pressed inside the listview.

Post a Comment for "Button Open A Fragment"