我可以更改让用户启用位置的dailog样式

时间:2016-05-12 06:52:42

标签: android google-maps google-play-services

我想更改google-service-lib显示的对话框样式 然后让用户按是或否然后打开位置而不进行位置设置 我可以做吗 ?这个链接有这个对话框的例子,如果我可以如何改变它 How to show enable location dialog like Google maps?

1 个答案:

答案 0 :(得分:0)

是。这是关于如何Create a Dialog Fragment

的代码段
public class FireMissilesDialogFragment extends DialogFragment {
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Use the Builder class for convenient dialog construction
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.dialog_fire_missiles)
               .setPositiveButton(R.string.fire, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       // FIRE ZE MISSILES!
                   }
               })
               .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       // User cancelled the dialog
                   }
               });
        // Create the AlertDialog object and return it
        return builder.create();
    }
}

其他样本: