ANDROID:如何从所有窗口顶部的通知或长按搜索按钮启动弹出对话框? [英] ANDROID: How can I launch a popup dialog from an notification or long-pressed search button on top of all windows?
问题描述
我搜索过,一切都是关于启动不是对话框的活动。
I have searched and everything is about launching an activity not a dialog.
我想做的是在状态栏中显示通知,当用户按下它之前,在点击通知之前弹出对话框。我不希望对话框显示在主要活动或最近的应用程序列表之上。
What I want to do is to display a notification in the status bar, and when the user presses it a dialog pops up on top of whatever the user was viewing before s/he clicked the notification. I dont want the dialog to show on top of the main activity or the recent apps list.
另外,如何从长按搜索按钮启动对话框?
Also, how can i launch the dialog from long pressing the search button?
谢谢! >
Thanks!
推荐答案
我从这里复制:这里是答案
开始活动作为对话框定义
to Start activity as dialog i defined
<activity android:theme="@android:style/Theme.Dialog">
现在当我 startActivity()
它显示像对话框和父活动显示在后面,我wan一个按钮,我点击对话框应该关闭,父活动应该显示,而不刷新页面。
now when i startActivity()
it display like dialog and parent activity display on back, i wan a button to whom i click dialog should dismiss and parent activity should display without refreshing the page.
然后有人添加评论:
使用 android:theme =@ android:style / Theme.Dialog
去,但不要忘记使用 excludeFromRecents = true
或者您的对话框将显示在最近使用的应用程序(按住Home键)。
Using the android:theme="@android:style/Theme.Dialog"
is the way to go but don't forget to use excludeFromRecents=true
or else your dialog will appear in the Recently Used Apps (hold the Home key).
而且长按可以重写 onKeyLongPress(int keyCode,KeyEvent事件)
,你可以使长按做你想要的。
http://developer.android.com/reference/android/view /View.html
And for the long press, override onKeyLongPress(int keyCode, KeyEvent event)
and you can make the long press do what you want.
http://developer.android.com/reference/android/view/View.html
这篇关于ANDROID:如何从所有窗口顶部的通知或长按搜索按钮启动弹出对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!