Dialog box embedding is device dependent

In my application, the user selects a phone number either from contacts or from the call log. The choice of contacts is quite simple and good on both phones and tablets - i. e. a new full-screen activity appears on the phones, and on the tables I see a nice pop-up dialog with a list of contacts.

There seems to be no way to select a phone number from the call log, so I had to implement my own activity (via ListFragment). I would like to achieve the same behavior as with contacts - on tablets I want to see a pop-up dialog box with a list, and on phones I want to see full-screen activity.

enter image description here

You can get what is shown in this figure without a code: "if it is displayed, then it is shown that the pop-up window starts a new activity", and to use only the selected styles / layouts depends on the device?

+3
source share
1 answer

It seems that the simplest solution - I am using ListFragment and do not want to sacrifice it DialogFragment - is to create different themes, it depends on the resolution (and platform).

For instance:

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> 
+2
source

All Articles