I want to calculate totals of T,T2,T3,T4 given in calculate method. if i don't put any value in calculate 3 (). there is show 0 value in T3.
I want full total of last row (Total) plz give me idea.. how it possible
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Edtinch1 = (EditText)findViewById(R.id.inch1);
Edtinch2 = (EditText)findViewById(R.id.inch2);
Edtfeet = (EditText)findViewById(R.id.feet);
Edtquan = (EditText)findViewById(R.id.qunt);
Totaltxt1= (EditText)findViewById(R.id.total1);
Edtquan.addTextChangedListener(this);
Edtinch21 = (EditText)findViewById(R.id.inch21);
Edtinch22 = (EditText)findViewById(R.id.inch22);
Edtfeet2 = (EditText)findViewById(R.id.feet2);
Edtquan2 = (EditText)findViewById(R.id.qunt2);
Totaltxt2= (EditText)findViewById(R.id.total2);
Edtquan2.addTextChangedListener(this);
Edtinch31 = (EditText)findViewById(R.id.inch31);
Edtinch32 = (EditText)findViewById(R.id.inch32);
Edtfeet3 = (EditText)findViewById(R.id.feet3);
Edtquan3 = (EditText)findViewById(R.id.qunt3);
Totaltxt3= (EditText)findViewById(R.id.total3);
Edtquan3.addTextChangedListener(this);
fulltotal1=(EditText)findViewById(R.id.fulltotal);
btnsnap = (Button)findViewById(R.id.btncapture);
btnsnap.setOnClickListener(this);
}
public void calculate(){
//get entered texts from the edittexts,and convert to integers.
inch11 = Double.parseDouble(Edtinch1.getText().toString());
inch12 = Double.parseDouble(Edtinch2.getText().toString());
feet11 = Double.parseDouble(Edtfeet.getText().toString());
quan11 = Double.parseDouble(Edtquan.getText().toString());
//do the calculation
Double calculated1 = (inch11*inch12)*(feet11)/144*(quan11);
//set the value to the textview, to display on screen.
T= calculated1.toString();
Totaltxt1.setText(T);
}
public void calculate2(){
//get entered texts from the edittexts,and convert to integers.
inch21 = Double.parseDouble(Edtinch21.getText().toString());
inch22 = Double.parseDouble(Edtinch22.getText().toString());
feet2 = Double.parseDouble(Edtfeet2.getText().toString());
quan2 = Double.parseDouble(Edtquan2.getText().toString());
//do the calculation
Double calculated2 = (inch21*inch22)*(feet2)/144*(quan2);
//set the value to the textview, to display on screen.
T2= calculated2.toString();
Totaltxt2.setText(T2);
}
public void calculate3(){
//get entered texts from the edittexts,and convert to integers.
inch31 = Double.parseDouble(Edtinch31.getText().toString());
inch32 = Double.parseDouble(Edtinch32.getText().toString());
feet3 = Double.parseDouble(Edtfeet3.getText().toString());
quan3 = Double.parseDouble(Edtquan3.getText().toString());
//do the calculation
Double calculated3 = (inch31*inch32)*(feet3)/144*(quan3);
//set the value to the textview, to display on screen.
T3= calculated3.toString();
Totaltxt3.setText(T3);
}
public void calculate4(){
//get entered texts from the edittexts,and convert to integers.
inch41 = Double.parseDouble(Edtinch41.getText().toString());
inch42 = Double.parseDouble(Edtinch42.getText().toString());
feet4 = Double.parseDouble(Edtfeet4.getText().toString());
quan4 = Double.parseDouble(Edtquan4.getText().toString());
//do the calculation
Double calculated4 = (inch41*inch42)*(feet4)/144*(quan4);
//set the value to the textview, to display on screen.
T4= calculated4.toString();
Totaltxt4.setText(T4);
}
public void fullcalculate()
{
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int arg1, int arg2,
int arg3) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
if (Edtinch1.getText().toString().length() <= 0)
{
Edtinch1.setError("Input Inch");
}
else if (Edtinch2.getText().toString().length() <= 0)
{
Edtinch2.setError("Input Inch");
}
else if (Edtfeet.getText().toString().length() <= 0)
{
Edtfeet.setError("Input feet");
}
else if (Edtquan.getText().toString().length() <= 0) {
Edtquan.setError("Input Quantity");
}
else
{
if (Edtquan.getText().hashCode() == s.hashCode())
{
calculate();
}
}
if (Edtinch21.getText().toString().length() <= 0)
{
Edtinch21.setError("Input Inch");
}
else if (Edtinch22.getText().toString().length() <= 0)
{
Edtinch22.setError("Input Inch");
}
else if (Edtfeet2.getText().toString().length() <= 0)
{
Edtfeet2.setError("Input feet");
}
else if (Edtquan2.getText().toString().length() <= 0) {
Edtquan2.setError("Input Quantity");
}
else
{
if (Edtquan2.getText().hashCode() == s.hashCode())
{
calculate2();
}
}
if (Edtinch31.getText().toString().length() <= 0)
{
Edtinch31.setError("Input Inch");
}
else if (Edtinch32.getText().toString().length() <= 0)
{
Edtinch32.setError("Input Inch");
}
else if (Edtfeet3.getText().toString().length() <= 0)
{
Edtfeet3.setError("Input feet");
}
else if (Edtquan3.getText().toString().length() <= 0) {
Edtquan3.setError("Input Quantity");
}
else
{
if (Edtquan3.getText().hashCode() == s.hashCode())
{
calculate3();
}
}
if (Edtinch41.getText().toString().length() <= 0)
{
Edtinch41.setError("Input Inch");
}
else if (Edtinch42.getText().toString().length() <= 0)
{
Edtinch42.setError("Input Inch");
}enter code here
else if (Edtfeet4.getText().toString().length() <= 0)
{
Edtfeet4.setError("Input feet");
}
else if (Edtquan4.getText().toString().length() <= 0) {
Edtquan4.setError("Input Quantity");
}
else
{
if (Edtquan4.getText().hashCode() == s.hashCode())
{
calculate4();
}
}
}
Aucun commentaire:
Enregistrer un commentaire