Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Button 如何在android中创建单键对话框?_Button_Dialog - Fatal编程技术网

Button 如何在android中创建单键对话框?

Button 如何在android中创建单键对话框?,button,dialog,Button,Dialog,我已经搜索了好几天,试图找出如何在我的应用程序中添加带有单个按钮的对话框。提前谢谢 对话框很简单,或者问题是如何确定更新是否正确? 这里是Dialogbuilder: AlertDialog.Builder builder = new AlertDialog.Builder(FisMapView.this); builder.setTitle("Update required"); builder.s

我已经搜索了好几天,试图找出如何在我的应用程序中添加带有单个按钮的对话框。提前谢谢

对话框很简单,或者问题是如何确定更新是否正确? 这里是Dialogbuilder:

AlertDialog.Builder builder = new AlertDialog.Builder(FisMapView.this);
                        builder.setTitle("Update required");
                        builder.setPositiveButton("UPDATE", new DialogInterface.OnClickListener() {                     
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            } 
                        });

                        builder.setNeutralButton("Abort", null);
                        AlertDialog alert = builder.create();
                        alert.show();
编辑:
我不知道如何检查市场上的更新,我建议将该版本与您自己的网站进行比较,如果您增加此网站上的版本号,请致电市场下载最新版本或从外部下载apk

将当前版本存储在您的应用程序DefaultSharedReferences中。在主活动上有一个变量,当在清单中增加版本时,该变量会增加。在运行期间,让它用代码中的版本检查当前版本,如果新版本更高,则执行一些操作。然后更新首选项中的一个

编辑:


如果他们点击对话框上的“取消”,请让程序结束,这样他们在每次打开程序时都会看到它,直到他们运行更新为止。

在主活动中,您有一个int currentVersion;每次你在市场上发布更新时,你都会增加它。在首选项中存储以前的版本。在onCreate()中,检查preferences中的previousVersion和代码中的currentVersion,并进行比较。如果currentVersion>previousVersion,则运行进行更改的代码并更新首选项,使previousVersion等于currentVersion。