Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

dialog with edittext android

 AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);
 alertDialog.setTitle("PASSWORD");
 alertDialog.setMessage("Enter Password");

 final EditText input = new EditText(MainActivity.this);
 LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
     LinearLayout.LayoutParams.MATCH_PARENT,
     LinearLayout.LayoutParams.MATCH_PARENT);
 input.setLayoutParams(lp);
 alertDialog.setView(input);
 alertDialog.setIcon(R.drawable.key);

 alertDialog.setPositiveButton("YES",
     new DialogInterface.OnClickListener() {
         public void onClick(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 = new Intent(view.getContext(),
                         Show.class);
                     startActivityForResult(myIntent1, 0);
                 } else {
                     Toast.makeText(getApplicationContext(),
                         "Wrong Password!", Toast.LENGTH_SHORT).show();
                 }
             }
         }
     });

 alertDialog.setNegativeButton("NO",
     new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
             dialog.cancel();
         }
     });

 alertDialog.show();
 }

 });
Comment

input edittext in android dialog

final View view = layoutInflater.inflate(R.layout.xml_file_created_above, null);
AlertDialog alertDialog = new AlertDialog.Builder(ct).create();
alertDialog.setTitle("Your Title Here");
alertDialog.setIcon("Icon id here");
alertDialog.setCancelable(false);
Constant.alertDialog.setMessage("Your Message Here");


final EditText etComments = (EditText) view.findViewById(R.id.etComments);

alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {

    }
});


alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Cancel", new OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        alertDialog.dismiss()
    }
});


alertDialog.setView(view);
alertDialog.show();
Comment

PREVIOUS NEXT
Code Example
Java :: java elapsedTime 
Java :: create jlabel 
Java :: android plain text remove underline 
Java :: android manifest internet permission 
Java :: mostrar todos los elementos de un arraylist java 
Java :: java how to create india currency 
Java :: android studio linearlayout set margin 
Java :: java take screenshot 
Java :: java print stacktrace to file 
Java :: junit 5 assert exception message 
Java :: void set method using collections 
Java :: display default value of auto commit java 
Java :: how to make background image transparent in android studio 
Java :: dreamworks studio recent movies 
Java :: java new string array 
Java :: Utils code for plugin minecraft 
Java :: java split array into two 
Java :: .tar to .ova 
Java :: how to find length of set in java 
Java :: java last element of array 
Java :: jersey test dependency 
Java :: renardfute 
Java :: public static int to String java 
Java :: throw io exception java 
Java :: check if object in array java 
Java :: Update UI on main thread Android 
Java :: android studio float to int 
Java :: convert date to calendar java 
Java :: first and last digit sum java 
Java :: multiply two strings 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =