Advertisement
Sketchware

Sistema senha simples

Jul 1st, 2023
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
  2. builder.setTitle("Digite a senha:");
  3.  
  4. // Configurar o campo de entrada de texto
  5. final EditText input = new EditText(MainActivity.this);
  6. input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
  7. builder.setView(input);
  8.  
  9. // Configurar o botão "OK"
  10. builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
  11.     @Override
  12.     public void onClick(DialogInterface dialog, int which) {
  13.         String senha = input.getText().toString();
  14.  
  15.         if (senha.equals("oab123")) {
  16.             anoi.setClass(getApplicationContext(), AnoTodoActivity.class);
  17.             startActivity(anoi);
  18.         } else {
  19.             SketchwareUtil.showMessage(getApplicationContext(), "SENHA INCORRETA, DIGITE NOVAMENTE!🙄");
  20.         }
  21.     }
  22. });
  23.  
  24. // Configurar o botão "Cancelar"
  25. builder.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
  26.     @Override
  27.     public void onClick(DialogInterface dialog, int which) {
  28.         dialog.cancel();
  29.     }
  30. });
  31.  
  32. // Exibir o diálogo
  33. builder.show();
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement