Android Studio上出现错误“eglSurfaceAttrib(1146):错误0x3009(EGL_BAD_MATCH)”

时间:2022-06-20 00:11:03

Trying to make a simple change view activity using an AlertDialog as input. but the error 'eglSurfaceAttrib(1146): error 0x3009 (EGL_BAD_MATCH)' appears:

尝试使用AlertDialog作为输入进行简单的更改视图活动。但出现错误'eglSurfaceAttrib(1146):错误0x3009(EGL_BAD_MATCH)':

Here is my AlertDialog Activity:

这是我的AlertDialog活动:

package caraoucoroa.studio.brunocasamassa.signos;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

/**
 * Created by bruno on 02/02/2017.
 */

public class MainActivity extends AppCompatActivity {

    private Button botao;
    private AlertDialog.Builder alert;



    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        setContentView(R.layout.activity_hello);

        botao = (Button) findViewById(R.id.button);

        botao.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {

                //creating alert
                alert = new AlertDialog.Builder(MainActivity.this);

                //alert title
                alert.setTitle("Entrando");

                //set message
                alert.setMessage("Deseja entrar?");
                alert.setCancelable(false);
                alert.setIcon(android.R.drawable.ic_delete);

                //Negative Button
                alert.setNegativeButton("Não", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(MainActivity.this,"Comeback Anytime", Toast.LENGTH_SHORT).show();
                    }
                });
                //Positive Button
                alert.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //startActivity(new Intent(MainActivity.this, SignosActivity.class));
                        Toast.makeText(MainActivity.this,"Comeback Anytime", Toast.LENGTH_SHORT).show();
                    }
                });
            }
        });




    }
}

1 个解决方案

#1


1  

AlertDialog.Builder builder1 = new AlertDialog.Builder(this);

builder1.setMessage("Are you sure you want to exit?");
builder1.setCancelable(true);

builder1.setPositiveButton(
        "Yes",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                MainActivity.this.finish();


            }
        });

builder1.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });

AlertDialog alert11 = builder1.create();
alert11.show();

#1


1  

AlertDialog.Builder builder1 = new AlertDialog.Builder(this);

builder1.setMessage("Are you sure you want to exit?");
builder1.setCancelable(true);

builder1.setPositiveButton(
        "Yes",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                MainActivity.this.finish();


            }
        });

builder1.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });

AlertDialog alert11 = builder1.create();
alert11.show();