截至上DialogFragment动作条行动 [英] Up ActionBar action on DialogFragment

查看:142
本文介绍了截至上DialogFragment动作条行动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 DialogFragment 是样式使用全屏的setStyle(STYLE_NORMAL,R.style.Theme_App)

I have a DialogFragment that is styled to full screen using setStyle(STYLE_NORMAL, R.style.Theme_App).

DialogFragment 显示正常,但后续行动(对在ActionBar的 homeAsUp 动作)不起作用。我试着在实施 onOptionsItemSelected DialogFragment ,但它永远不会被调用。

The DialogFragment shows fine but the up action (the homeAsUp action on the ActionBar) does not work. I tried implementing onOptionsItemSelected in the DialogFragment but it is never called.

有没有办法让在DialogFragment向上回调的动作,所以我可以辞退呢?作为参考,我使用 ActionBarCompat

Is there a way to get the up action callback in the DialogFragment so I can dismiss it ? For reference, I'm using ActionBarCompat.

推荐答案

有没有办法一个动作条连接到 DialogFragment 尽管你可以设置的主题 DialogFragment 也不会为一个动作条注册它, Dialog.getActionBar()将始终返回null。

There is no way to attach an ActionBar to the DialogFragment even though you can set the theme of the DialogFragment it will not register as a ActionBar to it, Dialog.getActionBar() will always return null.

非但没有的动作条你总是可以附加一个布局看起来像一个动作条,并使用菜单上设置的功能。

Instead of getting the ActionBar you can always attach a Layout that will look like an ActionBar and set the functionality on it using menu.

另一种方法是创建一个ActionBar的活动作为一个对话框,你可以参考这个职位

The other way is to create an activity with actionBar as a Dialog you can refer to this post

这篇关于截至上DialogFragment动作条行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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