例如。
empty 是第一个 EditText,total_empty 是另一个 Edit Text 如果我在空的 edittext 中键入 1,则它必须在 total_empty edittext 上同时显示为 1。
之后我有一个名为 new.i 的 EditText。我将在 EditText new 中给出 3 作为值。
之后,我必须添加上述三个 EditText 值(1+2+3)并在另一个名为 fill 的 EditText 中显示总和。
Atlast我有另一个名为total_fill的editText我也必须在上面的“fill”edittext中显示相同的值。
我的代码如下
编辑文本
empty_cyl_recvd,new_cyl_recvd,filled_cyl_unload,dmg_cyl_recvd,total_filled_cyl,total_dmg_cyl,total_em
pty_cyl;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
empty_cyl_recvd = (EditText) findViewById(R.id.empty_cyl_recvd);
empty_cyl_recvd.setInputType(InputType.TYPE_CLASS_NUMBER);
empty_cyl_recvd.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
new_cyl_recvd = (EditText) findViewById(R.id.new_cyl_recvd);
new_cyl_recvd.setInputType(InputType.TYPE_CLASS_NUMBER);
new_cyl_recvd.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
filled_cyl_unload = (EditText) findViewById(R.id.filled_cyl_unload);
filled_cyl_unload.setInputType(InputType.TYPE_CLASS_NUMBER);
filled_cyl_unload.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
dmg_cyl_recvd = (EditText) findViewById(R.id.dmg_cyl_recvd);
dmg_cyl_recvd.setInputType(InputType.TYPE_CLASS_NUMBER);
dmg_cyl_recvd.setKeyListener(DigitsKeyListener.getInstance("0123456789"));
total_dmg_cyl=(EditText)findViewById(R.id.sdff);
total_empty_cyl=(EditText)findViewById(R.id.wertyu);
total_filled_cyl=(EditText)findViewById(R.id.gfhgftg);
empty_cyl_recvd.addTextChangedListener(new TextWatcher()
{
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
int a=Integer.parseInt(empty_cyl_recvd.getText().toString());
int b=Integer.parseInt(Util.EMPTY_LIST.get(0).toString());
int c=a+b;
total_empty_cyl.setText(""+c);
}});
filled_cyl_unload.addTextChangedListener(new TextWatcher()
{
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
int a=Integer.parseInt(filled_cyl_unload.getText().toString());
int b=Integer.parseInt(Util.FILL_LIST.get(0).toString());
int c=a+b;
total_filled_cyl.setText(""+c);
}
});
dmg_cyl_recvd.addTextChangedListener(new TextWatcher(){
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
int a=Integer.parseInt(dmg_cyl_recvd.getText().toString());
int b=Integer.parseInt(Util.DAMAGE_LIST.get(0).toString());
int c=a+b;
total_dmg_cyl.setText(""+c);
}
});