I want to develop an android application using Honey Comb 3.0
in which I want to display a list , clicking on any item in a list should display another list beside that list item in the form of Fragment. Can any one provide me sample code in sorting out this issue?
Thanks in Advance,
Two fragments in one activity. A fragment represents a portion of user interface in an Activity, and provides a mechanism for creating reusable modules, after being created this module can be embedded within activities.
In Android Studio, Right click on main source set folder, click on New -> Activity -> Empty Activity. Now you have created the base activity. After creating the activity, we need to edit the xml file. In this blog, I’ll show How to display 2 fragments in the activity.
Recently Google have suggested that it’s better to use single activity for your applications. But what if your designer say that one UI should be on fullscreen, while another in simple mode, without drawing over status bar. Then for resolving this issue we will create one more Activity for Fullscreen and one Activity with Fragments for simple UI.
The fragment is something like Frame in Html. One Html can contain multiple Frames, and one Activity can include multiple Fragments. Each Fragment can have its own layout XML file, can contain its own view objects and encapsulate its own functionality. It can be reused by any activity.
Have a look at these two blog posts from Google's Reto Meier:
He has lots of code examples in there for handling fragments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With