Я новичок в android и пытаюсь разработать калькулятор подоходного налога как часть моего проекта. У меня есть около 8 полей на странице, и я хочу подвести все эти поля и отобразить их в текстовом виде. Я написал следующий код для этого:необходимо сделать расчет в android
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.widget.EditText;
import android.widget.TextView;
public class Tab2 extends Activity {
/** Called when the activity is first created. */
public int tot_ded=0;
public int value1=0;
public int value2=0;
public int value3=0;
public int value4=0;
public int value5=0;
public int value6=0;
public int value7=0;
public int value8=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab2);
EditText e1=(EditText)findViewById(R.id.txtHRA);
EditText e2=(EditText)findViewById(R.id.txt80C);
EditText e3=(EditText)findViewById(R.id.txthome_loan_inte);
EditText e4=(EditText)findViewById(R.id.txtmedi_ins_self);
EditText e5=(EditText)findViewById(R.id.txtmedi_ins_depe);
EditText e6=(EditText)findViewById(R.id.txtmedi_reim);
EditText e7=(EditText)findViewById(R.id.txtcon_allo);
EditText e8=(EditText)findViewById(R.id.txtprof_tax);
TextView Textv1 = (TextView)findViewById(R.id.txttotal_dedu);
//When I remove this code from comment, it stops my app.
/* value1=Integer.parseInt(e2.getText().toString());
value2=Integer.parseInt(e2.getText().toString());
value3=Integer.parseInt(e3.getText().toString());
value4=Integer.parseInt(e4.getText().toString());
value5=Integer.parseInt(e5.getText().toString());
value6=Integer.parseInt(e6.getText().toString());
value7=Integer.parseInt(e7.getText().toString());
value8=Integer.parseInt(e8.getText().toString());
tot_ded=value1+value2+value3+value4+value5+value6+value7+value8;*/
e7.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
//Textv1.setText(tot_ded);
}
}
});
}
}
Может кто-нибудь помочь мне. Я знаю, что вопрос ребяческий, но я действительно не знаю, что делать. Pls помогает мне.
Помощь вы что-то делаете? Где вы застряли? Ожидаете ли вы результата, который не придет? Что это за ожидание? – CinCout