[英]How to make a window in an activity?
I want to make a new window in an activity. 我想在活动中创建一个新窗口。 like a popup window. 像一个弹出窗口。 I saw the source code of the Email application shipped with android OS and found this 我看到了Android OS附带的Email应用程序的源代码,并发现了这一点
import com.android.internal.policy.PolicyManager
Window w = PolicyManager.makeNewWindow(mContext);
But I can't find such a class in the SDK. 但我在SDK中找不到这样的类。 Any idea? 任何想法?
android.widget.PopupWindow might be what you're after. android.widget.PopupWindow可能就是你所追求的。 http://developer.android.com/reference/android/widget/PopupWindow.html http://developer.android.com/reference/android/widget/PopupWindow.html
Depending on what you're trying to do though, you may prefer using a dialog or an activity that isn't fullscreen. 根据您尝试执行的操作,您可能更喜欢使用不是全屏的对话框或活动。
Just a side note. 只是旁注。 PopupWindow doesn't work well with Preferences screens. PopupWindow与Preferences屏幕不兼容。 AlertDialog is not themable. AlertDialog不可用。
You can use an AlertDialog or just use an Activity
but with a dialog theme placing: 您可以使用AlertDialog或只使用一个Activity
但对话框主题放置:
android:theme="@android:style/Theme.Dialog"
in your AndroidManifest
file. 在AndroidManifest
文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.