estoy usando un visor para mostrar desde un arrayadapter.it dinámico funciona, pero los datos que se muestran cambian irregularmente cuando me desplazo por la lista. Quiero que mi Vista de lista se llene solo una vez, No todo el tiempo cuando me desplazo por mi lista. ¿Alguna sugerencia? Aquí está mi código¿Cómo implementar un titular de vista?
public View getView(int position, View convertView, ViewGroup parent) {
// A ViewHolder keeps references to children views to avoid unneccessary calls
// to findViewById() on each row.
ViewHolder holder;
// When convertView is not null, we can reuse it directly, there is no need
// to reinflate it. We only inflate a new View when the convertView supplied
// by ListView is null.
if (convertView == null) {
convertView = mInflater.inflate(R.layout.sample, null);
// Creates a ViewHolder and store references to the two children views
// we want to bind data to.
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.text);
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
convertView.setTag(holder);
} else {
// Get the ViewHolder back to get fast access to the TextView
// and the ImageView.
holder = (ViewHolder) convertView.getTag();
}
// Bind the data efficiently with the holder.
if(_first==true)
{
if(id<myElements.size())
{
holder.name.setText(myElements.get(id));
holder.icon.setImageBitmap(mIcon1);
id++;
}
else
{
_first=false;
}
}
//holder.icon.setImageBitmap(mIcon2);
/*try{
if(id<myElements.size())
id++;
else
{
id--;
}
}
catch(Exception e)
{
android.util.Log.i("callRestService",e.getMessage());
}*/
return convertView;
}
static class ViewHolder {
TextView name;
ImageView icon;
}
cuando se carga la lista se parece a esto: http://i.stack.imgur.com/NrGhR.png después de desplazarse algunos datos http://i.stack.imgur.com/sMbAD.png
Parece que este, y otra vez si me desplazo al principio se ve http://i.stack.imgur.com/0KjMa.png
PD: mi lista debe estar en orden alfabético
¿puede publicar la captura de pantalla de su salida? –
@Tilsan The Fighter: ha publicado las instantáneas. – Ads