Bienvenido a proyecto on line, en este sitio vas a hallar la respuesta a lo que andabas buscando.
Ejemplo 1: diálogo con edittext android
AlertDialog.Builder alertDialog =newAlertDialog.Builder(MainActivity.this);
alertDialog.setTitle("PASSWORD");
alertDialog.setMessage("Enter Password");finalEditText input =newEditText(MainActivity.this);LinearLayout.LayoutParams lp =newLinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
input.setLayoutParams(lp);
alertDialog.setView(input);
alertDialog.setIcon(R.drawable.key);
alertDialog.setPositiveButton("YES",newDialogInterface.OnClickListener()publicvoidonClick(DialogInterface dialog,int which)
password = input.getText().toString();if(password.compareTo("")==0)if(pass.equals(password))Toast.makeText(getApplicationContext(),"Password Matched",Toast.LENGTH_SHORT).show();Intent myIntent1 =newIntent(view.getContext(),Show.class);startActivityForResult(myIntent1,0);elseToast.makeText(getApplicationContext(),"Wrong Password!",Toast.LENGTH_SHORT).show(););
alertDialog.setNegativeButton("NO",newDialogInterface.OnClickListener()publicvoidonClick(DialogInterface dialog,int which)
dialog.cancel(););
alertDialog.show();}});
Ejemplo 2: ingresar texto de edición en el diálogo de Android
finalView view = layoutInflater.inflate(R.layout.xml_file_created_above,null);AlertDialog alertDialog =newAlertDialog.Builder(ct).create();
alertDialog.setTitle("Your Title Here");
alertDialog.setIcon("Icon id here");
alertDialog.setCancelable(false);Constant.alertDialog.setMessage("Your Message Here");finalEditText etComments =(EditText) view.findViewById(R.id.etComments);
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE,"OK",newOnClickListener()@OverridepublicvoidonClick(DialogInterface dialog,int which));
alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE,"Cancel",newOnClickListener()@OverridepublicvoidonClick(DialogInterface dialog,int which)
alertDialog.dismiss());
alertDialog.setView(view);
alertDialog.show();
Recuerda difundir este ensayo si si solucionó tu problema.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)