我如何使用兼容包显示DialogFragment? [英] How can I show a DialogFragment using compatibility package?

查看:258
本文介绍了我如何使用兼容包显示DialogFragment?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着使用DialogFragment在3.0〜设备,这不支持片段或通过DialogFragment SDK水平。

I've tried to use DialogFragment on 3.0- devices, which not supports Fragment or DialogFragment by SDK level.

所以,我决定用Android的兼容性,支持片段。结果
然后,我创建了一个扩展类DialogFragment android.support.v4.app.DialogFragment

So, I decided to use Android compatibility library, which supports Fragment.
Then I created a DialogFragment class that extends android.support.v4.app.DialogFragment.

但.....当我试图用DialogFragment.show()我DialogFragment显示,我通知显示(FragmentManager,字符串)接受第一个参数为 android.app.FragmentManager ,不 android.support.v4.app.FragmentManager

But.....When I tried to show my DialogFragment using DialogFragment.show(), I notified that show(FragmentManager, String) accepts first argument as android.app.FragmentManager, not android.support.v4.app.FragmentManager.

我认为android.app.FragmentManager不能Android中使用3.0-设备,因为它不是在SDK中包含

I think android.app.FragmentManager cannot be used in Android 3.0- devices, because it is not included in SDK.

有什么办法,以显示与兼容性库DialogFragment?难道我必须用另一种方式来展现我与兼容库DialogFragment?

Is there any way to show DialogFragment with Compatibility library? Am I have to use another way to show My DialogFragment with compatibility library?

任何帮助将非常AP preciated。 :)

Any help will be much appreciated. :)

推荐答案

兼容性包是之前的3.0那些在Android版本开发。

The compatibility package is for those developing on Android versions prior to 3.0.

这两个 FragmentManager 和的 DialogFragment 类API级别存在11(3.0)

Both the FragmentManager and the DialogFragment classes exist in API level 11 (3.0)

在任何片段或活动,你应该能够做到以下几点在屏幕中间显示一个小(空)对话框:

In any Fragment or Activity you should be able to do the following to display a small (empty) dialog in the middle of the screen:

DialogFragment df = new DialogFragment();
df.show(getSupportFragmentManager(), "MyDF");

这篇关于我如何使用兼容包显示DialogFragment?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆