Advertisement
Sketchware

Mostra calendário edittext

Jan 12th, 2023
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.47 KB | None | 0 0
  1. Button btn = (Button) findViewById(R.id.button1);
  2. final EditText editText = (EditText) findViewById(R.id.editText1);
  3.  
  4. btn.setOnClickListener(new View.OnClickListener() {
  5.     @Override
  6.     public void onClick(View v) {
  7.         Calendar c = Calendar.getInstance();
  8.         int day = c.get(Calendar.DAY_OF_MONTH);
  9.         int month = c.get(Calendar.MONTH);
  10.         int year = c.get(Calendar.YEAR);
  11.         editText.setText(day + "/" + (month + 1) + "/" + year);
  12.     }
  13. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement