有谁知道如何让我的小部件打开带有输入框的对话框?
目前我有一个小部件,当用户单击它时,它会打开一个登录屏幕。我想跳过这一步,以便用户可以直接进入应用程序的功能。我看到其他应用程序执行此操作的方式是使用弹出对话框,允许用户在不打开整个活动的情况下进行输入。
当用户单击小部件中的某些内容时,我将如何弹出一个对话框。目前,我已经制作了自定义对话框类(即使普通对话框也可以),并且我尝试像正常活动一样调用它,但毫不奇怪,这不起作用。
还有人有其他想法吗?
这是错误发生时的输出(黑框是包名称):
At the moment I have a widget which, when the user clicks on it, opens a login screen. I want to skip this step so that the user can go straight to the functionality of the app. The way I have seen other apps do this is with pop-up dialogs that allow the user's to input without opening the entire activity.
How would I go about getting a dialog to pop-up when the user clicks something in the widget. At the moment I have the custom dialog class made (even though a normal dialog would do), and I have tried calling it just like a normal activity but at no surprise this didn't work.
Does anyone have any other ideas?
Here's the ouput when the error occurs (the black box is the package name):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法真正从小部件中显示对话框。您应该启动一个 Activity,但可以使用
Theme.Dialog
将其样式设置为对话框。You can't really show a Dialog from the Widget. You should start an Activity, but it can be styled as dialog using
Theme.Dialog
.在manifest.xml中......活动android:name =“.Activity”
android:theme="@android:style/Theme.Dialog"
android:label="@string/app_name"
in manifest.xml....... activity android:name=".Activity"
android:theme="@android:style/Theme.Dialog"
android:label="@string/app_name"
尝试这样做..还有另一件事不创建对话类..我的意思是不要扩展对话..扩展活动..`
导入 android.widget.Button;
导入 android.widget.EditText;
导入 android.widget.TextView;
公共类添加扩展活动{
//代码放在这里..
}
这是manifest.xml`
try doin this.. and another thing do not create dialogue class.. i mean do not extend Dialogue.. extend activity..`
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Add extends Activity {
//code goes here..
}
and this is the manifest.xml`