Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Button button = (Button) findViewById(R.id.your_button_id);
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
- builder.setTitle("Insira Assunto e Mensagem");
- final EditText subjectInput = new EditText(MainActivity.this);
- subjectInput.setHint("Assunto");
- final EditText messageInput = new EditText(MainActivity.this);
- messageInput.setHint("Mensagem");
- LinearLayout layout = new LinearLayout(MainActivity.this);
- layout.setOrientation(LinearLayout.VERTICAL);
- layout.addView(subjectInput);
- layout.addView(messageInput);
- builder.setView(layout);
- builder.setPositiveButton("Enviar", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- String subject = subjectInput.getText().toString();
- String message = messageInput.getText().toString();
- Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
- emailIntent.setData(Uri.parse("mailto: endereco_de_email@gmail.com"));
- emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
- emailIntent.putExtra(Intent.EXTRA_TEXT, message);
- startActivity(emailIntent);
- }
- });
- builder.setNegativeButton("Cancelar", null);
- builder.create().show();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement