Hackrsn

Prompt User Input with an AlertDialog

Dec 15th, 2015
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. la suite
  2.  
  3. http://adf.ly/1TWES8^^^^^^^
  4.  
  5.  
  6. AlertDialog. Builder alert = new AlertDialog. Builder( this );
  7. alert . setTitle (" Title ");
  8. alert . setMessage( " Message");
  9. // Set an EditText view to get user input
  10. final EditText input = new EditText ( this );
  11. alert . setView( input);
  12. alert . setPositiveButton( " Ok", new DialogInterface .OnClickListener () {
  13. public void onClick ( DialogInterface dialog , int whichButton ) {
  14. String value = input . getText();
  15. // Do something with value !
  16. }
  17. });
  18. alert . setNegativeButton( " Cancel", new DialogInterface . OnClickListener () {
  19. public void onClick ( DialogInterface dialog , int whichButton) {
  20. // Canceled .
  21. }
  22. });
  23. alert . show ();
Add Comment
Please, Sign In to add comment