3

In my app user picks phone number either from contacts or call log. Picking contacts is quite simple and works nice both on phones and tablets - i. e. on phones new fullscreen activity is popped up and on tables I see nice popup dialog with list of contacts.

It seems that there is no way to pick phone number from call log, so I had to implement my own activity (via ListFragment). I would like to achive same behavior as with contacts - on tablets I want to see popup dialog with list view, and on phones I want to see fullscreen activity.

enter image description here

It is possible to achive what is drawn on this pic without having code like: "if this is tabled then show popup else start new activity", and use only styles / layouts which are picked automatically depends on device?

lstipakov
  • 3,138
  • 5
  • 31
  • 46
  • 1
    you have to check only if there is a placeholder for Fragment ... and put this placeholder only in "tablet layout" ... so if there is placeholder you just use fragmentManager to put this list fragment there ...if not you have to start activity which contains this fragment ... – Selvin Jun 12 '12 at 12:04

1 Answers1

2

It seems that simpiest solution - I use ListFragment and don't want to sacrifice it to DialogFragment - is to create different themes depends on resolution (and platform).

For example:

AndroidManifest.xml

<activity
    android:name="CallLogActivity"
    android:theme="@style/dialog_or_activity">
</activity>

\values-xlarge-v11\styles.xml

<resources>
    <style name="dialog_or_activity" parent="android:Theme.Holo.Light.Dialog">                 
    </style>
</resources>

\values\styles.xml

<style name="dialog_or_activity" parent="android:Theme">        
</style>
lstipakov
  • 3,138
  • 5
  • 31
  • 46
  • you can also try fragment dialog instead of "Activity Dialog"(CallLogActivity) http://android-developers.blogspot.com/2012/05/using-dialogfragments.html – Selvin Jun 12 '12 at 14:09
  • yeah but then I couldn't use ListFragment and will have to write additional code to implement its functionality – lstipakov Jun 13 '12 at 10:25