对话框片段嵌入取决于设备 [英] Dialog fragment embedding depends on device
问题描述
在我的应用用户中,从联系人或通话记录中选择电话号码。选择联系人是非常简单的,在手机和平板电脑上工作很好 - 我。即在手机上弹出新的全屏活动,在表上我看到有联系人列表的漂亮弹出对话框。
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.
似乎没有办法从通话记录中选择电话号码,所以我不得不实现自己的活动(通过ListFragment)。我想要与联系人一样的行为 - 在平板电脑上,我想看到列表视图的弹出式对话框,以及我想要看到全屏活动的手机。
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.
可以查看在这个图片上绘制,而不用如下代码:如果这是提交然后显示弹出窗口启动新的活动,并且只使用自动选择的样式/布局取决于设备?
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?
推荐答案
似乎简单的解决方案 - 我使用ListFragment,不想牺牲它到DialogFragment - 是根据分辨率(和平台)创建不同的主题。
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).
例如:
AndroidManifest.xml
<activity
android:name="CallLogActivity"
android:theme="@style/dialog_or_activity">
</activity>
\values-xlarge-v11 \styles.xml p>
\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>
这篇关于对话框片段嵌入取决于设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!