> if you want to take advantage of defining the ListView once > and using it across multiple activities (e.g., one with the content > fragment for tablets/TVs and one without the content fragment for > phones), using a ListFragment is a good idea. The examples usually only have one Activity for the list view, for instance the one called "Activity A" in http://developer.android.com/guide/topics/fundamentals/fragments.html or the unnamed activity i assume would be called TitlesActivity in http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html.
The separation between tablets/TVs and phones are made using layout xml files and I guess this could be done with include instead if we have the ListView in a separate file and include it in one layout file for xlarge and another layout for normal. The benefit of ListFragment seems to be limited to the same benefits you have with a ListActivity. > > I'm also confused about the example at > >http://android-developers.blogspot.com/2011/02/android-30-fragments-a... > > where there seems to betwofragments, but the second one (called > > details) is declared as a FrameLayout in the xml. > > The fragment is added dynamically via a FragmentTransaction. It's only added in portrait orentation, i.e. FragmentTransaction.add() is only called in DetailsActivity.onCreate() and only after the ORIENTATION_LANDSCAPE check. So in landscape orientation it seems like a FrameLayout (with id R.id.details) is replaced by a fragment. But I guess replace() will ignore the fact that there is no fragment yet and just add the new one. Still a bit confusing that R.id.details is use as ID for both the FrameLayout and the fragment. On 22 Juni, 02:24, Mark Murphy <[email protected]> wrote: > On Tue, Jun 21, 2011 at 8:19 PM, nadam <[email protected]> wrote: > > In most Fragment exemples there aretwofragments, for instance a list > > to the left and a content area to the right where you see things you > > have selected in the list. Do you really needtwofragmentsfor this > > or could the left part be a simple ListView instead? > > You are welcome to write whatever you want. > > However, if you want to take advantage of defining the ListView once > and using it across multiple activities (e.g., one with the content > fragment for tablets/TVs and one without the content fragment for > phones), using a ListFragment is a good idea. > > > I'm also confused about the example at > >http://android-developers.blogspot.com/2011/02/android-30-fragments-a... > > where there seems to betwofragments, but the second one (called > > details) is declared as a FrameLayout in the xml. > > The fragment is added dynamically via a FragmentTransaction. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > Android Training in London:http://bit.ly/smand1,http://bit.ly/smand2 -- 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

