EditText quantity = (EditText) view.findViewById(R.id.dados_qtd_produto);
quantity.addTextChangedListener(new MyTextWatcher(view));
private class MyTextWatcher implements TextWatcher{
private View view;
private MyTextWatcher(View view) {
this.view = view;
}
public void afterTextChanged(Editable s) {
String qtyString = s.toString().trim();
int quantity = qtyString.equals("") ? 0:Integer.valueOf(qtyString);
EditText qtyView = (EditText) view.findViewById(R.id.dados_qtd_produto);
ItensPedidoModel itenspedido = (ItensPedidoModel) qtyView.getTag();
if(itenspedido.getQtd() != quantity){
Double currPrice = itenspedido.getExt();
Double extPrice = quantity * itenspedido.getPreco();
Double priceDiff = Double.valueOf(extPrice - currPrice);
itenspedido.setQtd(quantity);
itenspedido.setExt(extPrice);
TextView ext = (TextView) view.findViewById(R.id.ext);
if(itenspedido.getQtd() != 0){
ext.setText("R$" + itenspedido.getExt().toString().replace(".", ","));
}
else {
ext.setText("");
}
}
}
.Márcio Fornari
.Bacharel em Sistemas de Informação
.Contatos pelo Telefone: (49)8814 - 3378
.ou pelo e-mail: marciofornari@gmail.com
..........................................................................
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
0 comentários:
Postar um comentário