EditTexts dependent on an Android GridView [closed]

4

I have two EditTexts, one Discount Value, another Percentage and an ImageButton to update, all are in a GridView.

When you click on the ImageButton, the value entered in the percentage field must be converted to Double and assigned to the value field. The way I did it, I can not get the value typed 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;
            }
        });
    
asked by anonymous 02.03.2015 / 15:12

1 answer

0

Switching to

if (convertView == null) {
    convertView = mInflater.inflate(R.layout.grid_itens_pedido, parent, false);

    holder = new ViewHolder();

.... resto do código aqui ...

convertView.setTag(holder);

} else {
   holder = (ViewHolder) convertView.getTag();
}

Does not work?

    
02.03.2015 / 20:03