I’m making an application that parses text and images from the Internet and displays them in a ListView. This works fine.
In each of the rows of ListView, the ImageView has GONE visibility value.
I’m trying to, if a field of XML parsing has value “yes”, set the ImageView‘s visibility to VISIBLE.
public class MinAdapterSuscr extends BaseAdapter {
//...
public View getView(int position, View convertView, ViewGroup parent)
{
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.list_row_my_nets, null);
TextView title = (TextView)vi.findViewById(R.id.title);
TextView net = (TextView)vi.findViewById(R.id.net);
ImageView home = (ImageView)vi.findViewById(R.id.enthome);
ImageView thumb_image=(ImageView)vi.findViewById(R.id.image);
HashMap<String, String> onets = new HashMap<String, String>();
onets = data.get(position);
// añadiendo los valores al listview
title.setText(android.text.Html.fromHtml(onets.get(netsActivity.KEY_NOMBRE_RED_SUSCR)));
artist.setText(android.text.Html.fromHtml(onets.get(netsActivity.KEY_DESCR_RED_SUSCR)));
nuevasEntradas.setText(android.text.Html.fromHtml(onets.get(netsActivity.KEY_POR_VER_SUSCR)));
String isHome = onets.get(netsActivity.KEY_ES_INICIO_SUSCR);
imageLoader.DisplayImage(song.get(netsActivity.KEY_AVATAR_RED_SUSCR), thumb_image);
// Comprobación de si es red propia o de inicio
if(isHome.equals("yes")) {
home.setVisibility(View.VISIBLE);
Log.i("looking",”home visible”);
}
return vi;
}
}
This works, but it shows results that seem random. Sometimes the ImageView is visible, sometimes not, but does not match the “yes” of the XML.
What am I doing wrong? I appreciate your help.
Regards
Just add else part also in if conition,
Try this and let me know what happen..