Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think I understood your problem. You have a custom adapter. Each item within the adapter contains 2 buttons and a progress bar. The buttons control their own respective progress bar's visibility.</p> <p>My spanish is weak but I think I understood your code. Haven't tested this, but it should get you close. You were storing something within the Progressbar's tag which I removed. Couldn't figure out what you were doing there but you can easily add that back in. It looks like you were trying to follow the ViewHolder paradigm but messed up a little. Hopefully the below code will get you on track.</p> <p>Also, storing the ArrayAdapters context in a static global field is not a good idea. The ArrayAdapter already has the method getContext() to use within the Adapter itself. Otherwise you shouldn't have a need to access it's context externally.</p> <p><strong>Update</strong>: Oh I see, you want to track the Adapter's item's position as well. No need to store that within the ProgressBar's tag. Modified sample code to account for that.</p> <p><strong>Update</strong>: Reformed code to function properly.</p> <pre class="lang-java prettyprint-override"><code>public class CustomAdapterRutinaDiaLineas extends ArrayAdapter&lt;Rutina&gt; { ArrayList&lt;Rutina&gt; lstRutinaDia; ArrayList&lt;Rutina&gt; arrayDatos; Rutina objRutina; public CustomAdapterRutinaDiaLineas(Context contexto, ArrayList&lt;Rutina&gt; arrayDatos) { super(contexto, R.layout.ll_lineas_rutina_dia, arrayDatos); this.arrayDatos = arrayDatos; } @Override public View getView(int position, View convertView, ViewGroup parent) { View vistaFila = null; ViewHolder vh; if (convertView == null) { LayoutInflater vi = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); vistaFila = vi.inflate(R.layout.ll_lineas_rutina_dia, null); vh = new ViewHolder(); vh.position = position; vh.btnOk = (Button) v.findViewById(R.id.btnLineasRutinaDiaOk); vh.btncerrar = (Button) v.findViewById(R.id.btnLineasRutinaDiaEjercicioNoCompletado); vh.pgrProgresoCierre = (ProgressBar) v.findViewById(R.id.pgrLineasRutinaDiaProgreso); vh.btnOk.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { ((ProgressBar)v.getTag()).setVisibility(View.VISIBLE); } }); vh.btncerrar.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { ((ProgressBar)v.getTag()).setVisibility(View.INVISIBLE); } }); vh.btncerrar.setTag(vh.pgrProgresoCierre); vh.btnOk.setTag(vh.pgrProgresoCierre); vistaFila.setTag(vh); } else { vistaFila = convertView; vh = (ViewHolder) vistaFila.getTag(); vh.position = position; } Rutina datossss = arrayDatos.get(position); if (datossss.getProgreso() == null) { datossss.setProgreso(vh.pgrProgresoCierre); } return vistaFila; } private static class ViewHolder { int position; Button btnOk; Button btnCerrar; ProgressBar pgrProgresoCierre; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload