**I have a row.xml file to my listview i trying use a button in my row to send a email but that button dont work ** i used this comand to take a button but he do anyting
i put a button but it seams that nothing heapining in the button i put a event in there
public class row extends AppCompatActivity {
Button btnEnviarEmail;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.row);
btnEnviarEmail=findViewById(R.id.BtnEnviarEmail);
btnEnviarEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
>here is my intent i dont know why its not working
//Criando a Intent
String[] TO={""};
String[]CC={""};
Intent intent=new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("mailto"));
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_CC,CC);
intent.putExtra(Intent.EXTRA_EMAIL,TO);
intent.putExtra(Intent.EXTRA_SUBJECT,"Enter your body for subject");
intent.putExtra(Intent.EXTRA_TEXT,"Body of the Mail");
try {
startActivity(Intent.createChooser(intent,"Sending Email"));
}catch (android.content.ActivityNotFoundException ex ){
ex.printStackTrace();//impossibilita a aplicação de crashar
}
}
});
}
}```
[enter image description here][1]
[1]: https://i.stack.imgur.com/Yy1r7.jpg
>thats my adapter i wanna get the email text to send automatically you know?
**When i get the field txtEmail so i put auto in my mensage**
public View getView(int position, View convertView, ViewGroup parent) {
View row=convertView;
ViewHolder holder=new ViewHolder();
if (row==null){
LayoutInflater inflater=(LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
row=inflater.inflate(layout,null);
holder.txtnome=row.findViewById(R.id.txtNome);
Button pegarEmail=(Button)row.findViewById(R.id.BtnEnviarEmail);
pegarEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Criando a Intent
String[] TO={""};
String[]CC={""};
Intent intent=new Intent(Intent.ACTION_SEND);
intent.setData(Uri.parse("mailto"));
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_CC,CC);
intent.putExtra(Intent.EXTRA_EMAIL,TO);
intent.putExtra(Intent.EXTRA_SUBJECT,"Enter your body for subject");
intent.putExtra(Intent.EXTRA_TEXT,"Body of the Mail");
try {
context.startActivity(Intent.createChooser(intent,"Sending Email"));
}catch (android.content.ActivityNotFoundException ex ){
ex.printStackTrace();//impossibilita a aplicação de crashar
}
}
});
holder.txttelefone=row.findViewById(R.id.txtTelefone);
holder.txtdataNascimento=row.findViewById(R.id.txtDataNascimento);
holder.txtEmail=row.findViewById(R.id.txtEmail);
holder.txtprovidencia=row.findViewById(R.id.txtProvidencias);
holder.imageView=row.findViewById(R.id.imgIcon);
row.setTag(holder);
}
else {
holder=(ViewHolder)row.getTag();
}
Model model =recordList.get(position);
holder.txtnome.setText(model.getNome());
holder.txttelefone.setText(model.getTelefone());
holder.txtdataNascimento.setText(model.getDataNascimento());
holder.txtEmail.setText(model.getEmail());
holder.txtprovidencia.setText(model.getProvidencias());
byte[] recordImage=model.getImage();
Bitmap bitmap = BitmapFactory.decodeByteArray(recordImage,0,recordImage.length);
holder.imageView.setImageBitmap(bitmap);
return row;
//Criando a Intent
//impossibilita a aplicação de crashar
}```