问题标签 [android-dialogfragment]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
android - DialogFragment 在调用 startActivity() 时使 Activity 崩溃
我有一个DialogFragment
应该很简单的,但它给了我一些特别是果冻豆的大问题。
该应用程序使用网络并弹出一个对话框,要求用户打开 WiFi 或取消然后关闭它。因此它扩展DialogFragment
并创建视图为:
如果用户单击“是”,它会关闭对话框并打开“无线设置”活动。或者,如果用户单击“取消”,它只会关闭我的整个活动,但在 Jelly Bean 上,只要我单击“是”,它就会打开“设置”,但应用程序强制关闭并出现以下错误:
有一些额外的日志记录显示了我布局上每个片段的保存状态,而应该是的数字 2SettingsDialogFragment
只是一个null
:
我试图不忽略对话,但它以同样的方式崩溃。
我真的不确定这里发生了什么……有什么想法吗?
编辑:
活动代码(这是一个正常活动,因为应用程序针对 ICS 及更高版本):
android - 如何忽略 DialogFragment 中的“搜索”按键
我之前为我的对话框扩展了类,我必须在我的对话框中使用以下代码段,以便在按下手机的搜索键Dialog
时它们不会被关闭:
我现在正在使用DialogFragment
该类进行对话。不幸的是,与按下手机的搜索键时对话框被取消DialogFragment
的问题相同(无论对话框的可取消状态如何)。双重问题是没有方法,因此上述代码段不再适用。Dialog
DialogFragment
setOnKeyListener
任何人都知道如何让我的对话框(显示时)忽略搜索按键?
注意:我尝试将上述代码段添加到我的活动
onKeyUp
方法中,但不幸的是,如果显示实例,onKeyUp
则不会调用我的活动方法。DialogFragment
相反,令人恼火的是,DialogFragment
实例被解雇了。
android - Full screen DialogFragment
I am trying to create a DialogFragment with a width of MATCH_PARENT so the dialog is nearly full screen (leaving the padding around the edges for the floating look). I have seen this solution Full Screen DialogFragment in Android but am trying to avoid the hack of setting the width to 1000dp. With my current layout, whether I use FILL_PARENT or MATCH_PARENT it seems to be setting the width and height to WRAP_CONTENT.
I have used this solution for Dialog (not DialogFragment) and it works as expected:
android - 运行时配置更改后 DialogFragment 变为 null
我正在学习使用Fragment
and DialogFragment
。作为培训,我正在尝试扩展DialogFragment pageAlertDialog
中给出的示例。显然一切都很好:当我显示选项菜单并单击其按钮时,会出现一个对话框,它的行为与预期一样。但是,如果在显示对话框时配置更改(例如,当我旋转屏幕时),则会正确重新创建对话框,但单击其任何按钮会使应用程序崩溃。我已经尝试了很多东西(例如,静态、、方法和其他记录在案的建议)来解决问题,但似乎没有任何效果,所以我处于起点。我正在使用支持库 v4。newInstance
setRetainInstance
onSaveInstanceState
这是我的主要活动代码:
这是我的DialogFragment
代码:
当单击取消按钮后执行崩溃时,logcatNullPointerException
在 doNegative 方法中显示一个。如果在单击 OK 按钮后NullPointerException
发生崩溃,则在 doPositive 方法中发生。DialogFragment
对象为空似乎很明显。
有人可以帮我吗?TIA
android - DialogFragment - setting initial values and retaining state after rotation
I have created an DialogFragment which is building and returning AlertDialog from onCreateDialog method. The AlertDialog contains two EditText views.
I'm setting the initial values of these two edit texts in the onCreateDialog method which works great until I rotate the phone and all changes get lost/restored to initial values because the onCreateDialog is recalled.
So my question is where should I place the initial values so they are only set the very first time you open the dialog and if you have done changes and you rotate your phone, the last state i retained and retached?
Below I have pasted simplified version of my code. One solution could be initializing the class attributes at newInstance() method, but then I need to make them static. Other solution could be passing the values through the Bundle, but no put-methods take Calendar as parameter type.
What is best practice?
}
android - API 级别 < 8 的 Dialog.setOnShowListener() 替代方案
我有一个AlertDialog
通过DialogFragment.onCreateDialog()
. 该对话框有一个EditText
和两个按钮,确定和取消。单击“确定”按钮时,我需要检查EditText
: 如果内容错误,则不应关闭对话框。在 SO 上搜索我发现可以通过这种方式轻松实现此功能:
问题是我正在使用支持库 v4,但setOnShowListener()
需要 API 级别 8 或更高。有人可以给我一个替代方案吗?TIA
android - 为 AlertDialog 的入口和出口设置动画
我必须AlertDialog
在它进入时滑入并在它被关闭时将其滑出,但它没有动画。
那么如何让动画工作呢?
这是我所拥有的,
主题.xml
我参考了太多资源,似乎没有一种适合我的正确方法,可能是我遗漏了什么
我在用
- 安卓 ICS
- 应用程序是为 API 15+ 构建的
以下是一些我无法得到答案的相关资源
android - 使 DialogFragment 适合图像大小
我有一个带有 ViewPager 的 DialogFragment,它显示了一些图片。问题是顶部有一条奇怪的黑色条纹,并且这些图片变形了。
这是我目前拥有的,正如你所看到的,图片看起来不太好,对话框顶部有一条奇怪的黑色条纹。
这是它应该看起来的样子,没有黑色条纹,并且图片适合屏幕的宽度。
我怎么能这样做?
提前非常感谢。
android - 处理 DialogFragment 中的按钮点击
我有扩展 DialogFragment 的片段,并且我有一个自定义布局,其中包含两个编辑文本和两个按钮 - 确定并取消。我的对话框显示得很好,使用 onCreateView 方法指定布局,但我不知道如何处理按钮点击。在 onCreateView 方法中,button.setOnClickListener 不起作用。这可能有一个简单的解决方案,但我被困了几个小时。我非常感谢您的建议或示例代码。
PS我不想使用AlertDialog,因为在这种情况下,当单击确定按钮时,对话框会自动关闭,并且我无法对edittext进行验证(例如:当用户按下确定按钮和edittext的是空的,我不希望对话框消失)。这就是我选择创建自定义对话框并轻松管理按钮行为的方式。
android-dialogfragment - datepicker dialog using DialogFragment for multiple activities
I need to use DatePicker dialog using the new DialogFragment class for multiple activities. I am having more than two activities using datepicker and time picker. I succeeded using the example in developer.android.com for Dialog Fragment for single activity.
#xA;If I use that I have to write different DialogFragment classes for each activities. Is there any solution like using switch case provided in this example?
#xA;