4
I have two Edittexts, a discount value, a percentage and an update Imagebutton, all are in a Gridview.
When clicking on the Imagebutton, the value entered in the percentage field should be converted to Double and assigned to the value field. The way I did, I can’t get the entered value in the percentage field.
Follow the code snippet:
@SuppressLint({ "InflateParams", "UseValueOf" })
public View getView(  final int position, View convertView, ViewGroup parent) {
    holder = null;
     if (convertView == null|| convertView.getTag()== null) {
        convertView = mInflater.inflate(R.layout.grid_itens_pedido, parent, false);
        holder = new ViewHolder();
        holder.etValorDesc.setTag(new Integer(position));
        holder.etDescontoSaida.setTag(new Integer(position));
        holder.imgAtualizar.setTag(new Integer(position));
        holder.etDescontoSaida.addTextChangedListener(new TextWatcher() {
            public void afterTextChanged(Editable s) {
               values[position].Desconto= Double.parseDouble(s.toString())/100;
            }
            public void beforeTextChanged(CharSequence s, int start,
                int count, int after) {
            }
            public void onTextChanged(CharSequence s, int start,
                int before, int count) {
            }
        });
        holder.imgAtualizar.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Integer position = (Integer)v.getTag();
                holder.etValorDesc.setText(String.valueOf(values[position].Desconto));
                return false;
            }
        });
The converted value is being converted and assigned to the class, however, I still cannot recover this value and assign to the discount value field.
– Fabio Calefi
Not missing either : Holder.etValorDesc = (Edittext) convertView.findViewById(R.id.field_name);
– Alexandre
No, I had already started this component.
– Fabio Calefi