-1
我有四個文本框,我希望當他們被檢查時,他們發送一個電子郵件的意圖,我有一個文本值。例如,如果選中「我查看電視」文本框,則在郵件中顯示「電視已選中」。 Here's java代碼:複選框發送電子郵件?
package com.example.kapscht;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.view.View.OnClickListener;
public class MainActivity extends Activity implements OnClickListener{
CheckBox checkcable;
CheckBox checkmodulo;
CheckBox checkantena ;
CheckBox checkampli ;
EditText etlugar;
EditText etfecha;
EditText etcable;
EditText etantena;
EditText etampli;
EditText etmodulo;
EditText etqe;
String l= "Lugar:";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etlugar = (EditText) findViewById(R.id.etlugar);
etfecha = (EditText) findViewById(R.id.etfecha);
etcable = (EditText) findViewById(R.id.etcable);
etantena = (EditText) findViewById(R.id.etantena);
etampli = (EditText) findViewById(R.id.etampli);
etmodulo = (EditText) findViewById(R.id.etmodulo);
etqe = (EditText) findViewById(R.id.etqe);
checkcable = (CheckBox) findViewById(R.id.checkcable);
checkmodulo = (CheckBox) findViewById(R.id.checkmodulo);
checkantena = (CheckBox) findViewById(R.id.checkantena);
checkampli = (CheckBox) findViewById(R.id.checkampli);
View boton = (Button) findViewById(R.id.enviar);
boton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v.getId()==findViewById(R.id.enviar).getId())
{
Intent intentEmail = new Intent(Intent.ACTION_SEND, Uri.fromParts("mailto", "[email protected]", null));
intentEmail.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
intentEmail.putExtra(Intent.EXTRA_SUBJECT, "Consulta Técnica");
intentEmail.putExtra(Intent.EXTRA_TEXT, "Lugar:"+etlugar.getText()+"\nFecha: "+etfecha.getText()+"\nComentarios módulo:"+etmodulo.getText()+"\nComentarios Antena: "+etantena.getText()+"\nComentarios cable:"+etcable.getText()+"\nComentarios Amplificador: "+etampli.getText()+"\nEnviado por: "+etqe.getText());
intentEmail.setType("message/rfc822");
startActivity(Intent.createChooser(intentEmail, "Enviar"));
}}}