Note that there are some explanatory texts on larger screens.

plurals
  1. POv.getTag() returns null instead of ViewHolder
    primarykey
    data
    text
    <p>I have a customized adapter that has a header and customized rows. Sometimes my v.getTag() returns null where I have stored my ViewHolder. It does not happen all the times and I can not figure out when and why it accurs. </p> <pre><code>@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; //Header if(items.hasDescription() &amp;&amp; 0 == position) { LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.app_list_header, null); ((TextView) v.findViewById(R.id.app_list_header_description_text)).setText(items.getDescription()); return v; } ViewHolder holder; // Inflate app view. if (v == null || v.getTag() == null) { LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(textViewResourceId, null); //TODO: parent instead of null? holder = new ViewHolder(); holder.title = (TextView) v.findViewById(R.id.title); holder.company = (TextView) v.findViewById(R.id.company); holder.priceOrStatus = (TextView) v.findViewById(R.id.price); holder.rating = (RatingBar) v.findViewById(R.id.rating); holder.icon = (ImageView) v.findViewById(R.id.icon); v.setTag(holder); } else { holder = (ViewHolder) v.getTag(); } } App app; if(items.hasDescription()) { app = items.get(position-1); } else { app = items.get(position); } // TODO: Do we need this? if (null == app || null == holder) { Log.d(TAG, "app: " +app +" holder: " +holder); return v; } //TODO: FIX THE XML BEFORE SO WE DO NOT NEED TO TRIM IT. // And get rid of all these ifs!! if(holder.title != null) { holder.title.setText(app.getTitle().trim()); } </code></pre> <p>Can anyone help me out?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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