我正在尝试更改附加到EditText(金额)的setOnEditorActionListener
事件中的TextView(totacost)的值,但它不起作用。
x是一个对象,x.setAmount()
是x
上改变x.totalcost
值的方法,我需要在textview中设置x.totalcost
的新值。
amount.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH ||
actionId == EditorInfo.IME_ACTION_DONE ||
event.getAction() == KeyEvent.ACTION_DOWN ||
event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
x.setAmount(Integer.parseInt(v.getText().toString()));
totalcost.setText(""+x.totalcost)
return true; // consume.
}
return false;
}
});