Meu problema está nesta parte
String mmessage = “Nome da loja: \n” + nameloja.getText().toString()+"\n\nNota da Loja:\n " + res +"\n\n O que falta nestá loja:\n\n" + notChecked();
não estou conseguindo fazer ele puxa o valor que é o res
String res = String.valueOf(num1 + num2 + num3 + num4 + num5 + num6 + num7 + total);
package projetoleandro.myapplication;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
import static projetoleandro.myapplication.R.id.a;
import static projetoleandro.myapplication.R.id.email;
import static projetoleandro.myapplication.R.layout.first;
public class FirstActivity extends Activity {
/**
* Called when the activity is first created.
*/
// private CheckBox a, s, d, f, g;
private List<CheckBox> lista = new ArrayList<>();
@Override
protected void onResume() {
super.onResume();
notChecked();
}
public String notChecked() {
String texto = "";
for (int i = 0; i < lista.size(); i++) {
if (!lista.get(i).isChecked()) {
texto = texto.concat(lista.get(i).getText().toString() + "\n");
}
}
return texto;
}
CheckBox a;
CheckBox s;
CheckBox d;
CheckBox f;
CheckBox g;
CheckBox h;
CheckBox j;
CheckBox k;
CheckBox q;
CheckBox w;
CheckBox e;
CheckBox rr;
CheckBox y;
CheckBox u;
CheckBox i;
CheckBox z;
CheckBox x;
CheckBox c;
CheckBox v;
CheckBox b;
CheckBox n;
CheckBox m;
CheckBox aa;
CheckBox ss;
CheckBox dd;
CheckBox ff;
EditText nameloja;
EditText hh, jj, kk, fr, qq, ww, ee;
Button sendEmailButton;
EditText emailAddress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(first);
emailAddress = (EditText) findViewById(R.id.email);
sendEmailButton = (Button) findViewById(R.id.enviar);
sendEmailButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String toemailAddress = emailAddress.getText().toString();
String mmessage = "Nome da loja: \n" + nameloja.getText().toString()+"\n\nNota da Loja:\n " + res +"\n\nO que falta nestá loja:\n\n" + notChecked();
Intent emailApp = new Intent(Intent.ACTION_SEND);
emailApp.putExtra(Intent.EXTRA_EMAIL, new String[]{toemailAddress});
emailApp.putExtra(Intent.EXTRA_TEXT, mmessage);
emailApp.setType("message/rfc822");
startActivity(Intent.createChooser(emailApp, "Send Email Via"));
}
});
a = (CheckBox) findViewById(R.id.a);
s = (CheckBox) findViewById(R.id.s);
d = (CheckBox) findViewById(R.id.d);
f = (CheckBox) findViewById(R.id.f);
g = (CheckBox) findViewById(R.id.g);
h = (CheckBox) findViewById(R.id.h);
j = (CheckBox) findViewById(R.id.j);
k = (CheckBox) findViewById(R.id.k);
q = (CheckBox) findViewById(R.id.q);
w = (CheckBox) findViewById(R.id.w);
e = (CheckBox) findViewById(R.id.e);
y = (CheckBox) findViewById(R.id.y);
u = (CheckBox) findViewById(R.id.u);
i = (CheckBox) findViewById(R.id.i);
z = (CheckBox) findViewById(R.id.z);
x = (CheckBox) findViewById(R.id.x);
c = (CheckBox) findViewById(R.id.c);
v = (CheckBox) findViewById(R.id.v);
b = (CheckBox) findViewById(R.id.b);
n = (CheckBox) findViewById(R.id.n);
m = (CheckBox) findViewById(R.id.m);
rr = (CheckBox) findViewById(R.id.rr);
aa = (CheckBox) findViewById(R.id.aa);
ss = (CheckBox) findViewById(R.id.ss);
dd = (CheckBox) findViewById(R.id.dd);
ff = (CheckBox) findViewById(R.id.ff);
lista.add(a);
lista.add(s);
lista.add(d);
lista.add(f);
lista.add(g);
lista.add(h);
lista.add(j);
lista.add(k);
lista.add(q);
lista.add(w);
lista.add(e);
lista.add(y);
lista.add(u);
lista.add(i);
lista.add(z);
lista.add(y);
lista.add(u);
lista.add(i);
lista.add(z);
lista.add(x);
lista.add(c);
lista.add(v);
lista.add(b);
lista.add(n);
lista.add(m);
lista.add(rr);
lista.add(aa);
lista.add(dd);
lista.add(ff);
hh = (EditText) findViewById(R.id.hh);
jj = (EditText) findViewById(R.id.jj);
kk = (EditText) findViewById(R.id.kk);
fr = (EditText) findViewById(R.id.fr);
qq = (EditText) findViewById(R.id.qq);
ww = (EditText) findViewById(R.id.ww);
ee = (EditText) findViewById(R.id.ee);
nameloja = (EditText) findViewById(R.id.nameloja);
Button bttotal = (Button) findViewById(R.id.btsomar);
bttotal.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
double total = 0;
if (a.isChecked()) {
total += 10.0;
}
if (s.isChecked()) {
total += 5.00;
}
if (d.isChecked()) {
total += 5.00;
}
if (f.isChecked()) {
total += 4.00;
}
if (g.isChecked()) {
total += 1.00;
}
if (h.isChecked()) {
total += 1.00;
}
if (j.isChecked()) {
total += 1.00;
}
if (k.isChecked()) {
total += 2.00;
}
if (q.isChecked()) {
total += 1.00;
}
if (w.isChecked()) {
total += 2.00;
}
if (e.isChecked()) {
total += 2.00;
}
if (rr.isChecked()) {
total += 1.00;
}
if (y.isChecked()) {
total += 3.50;
}
if (u.isChecked()) {
total += 1.00;
}
if (z.isChecked()) {
total += 4.50;
}
if (x.isChecked()) {
total += 6.00;
}
if (c.isChecked()) {
total += 4.50;
}
if (v.isChecked()) {
total += 1.00;
}
if (b.isChecked()) {
total += 1.00;
}
if (z.isChecked()) {
total += 4.50;
}
if (n.isChecked()) {
total += 6.00;
}
if (m.isChecked()) {
total += 4.00;
}
if (aa.isChecked()) {
total += 1.50;
}
if (ss.isChecked()) {
total += 2.00;
}
if (dd.isChecked()) {
total += 2.50;
}
if (ff.isChecked()) {
total += 2.00;
}
double num1 = Double.parseDouble(hh.getText().toString());
double num2 = Double.parseDouble(jj.getText().toString());
double num3 = Double.parseDouble(kk.getText().toString());
double num4 = Double.parseDouble(qq.getText().toString());
double num5 = Double.parseDouble(ww.getText().toString());
double num6 = Double.parseDouble(ee.getText().toString());
double num7 = Double.parseDouble(fr.getText().toString());
String res = String.valueOf(num1 + num2 + num3 + num4 + num5 + num6 + num7 + total);
String alert3 = "Nome da loja: \n" + nameloja.getText().toString();
String alert1 = "\n\n Nota da Loja:\n " + res;
String alert2 = "\n\n O que falta nestá loja:\n\n" + notChecked();
// Instância
AlertDialog.Builder dialogo = new AlertDialog.Builder(FirstActivity.this);
// setando título
dialogo.setTitle("Resultado");
// setando mensagem
dialogo.setMessage(alert3 + alert1 + alert2);
// setando botão
dialogo.setNeutralButton("OK", null);
// chamando o AlertDialog
dialogo.show();
}
});
}
}