Note that there are some explanatory texts on larger screens.

plurals
  1. POListview with images, but when scroll the List, the images apear in wrong rows
    primarykey
    data
    text
    <p>The image (in this moment just one for one specified country), when I scroll the listview appears in some rows, when should appear in just one specified row. </p> <p>Example: in the row "france", appear the flag of france, but then, the same flag appears in other rows. Not in all rows. At the moment, I'm only testing with the flag of france. </p> <pre><code>public class MyListAdapter extends SimpleCursorAdapter{ private Cursor cur; private Context context; private SQLiteDatabase db; private static final String ASSETS_DIR = "images/"; private String Flag; public MyListAdapter (Context context, Cursor c, SQLiteDatabase db) { super(context, R.layout.countries_list_item, c, new String[] {}, new int[] {}); this.cur=super.getCursor(); this.context = context; this.db=db; } private class ViewHolder { TextView txtTitle, txtDate; ImageView countryIcon; } public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.countries_list_item, null); holder = new ViewHolder(); holder.txtTitle = (TextView) convertView.findViewById(R.id.lastName); holder.txtDate = (TextView) convertView.findViewById(R.id.firstName); holder.countryIcon = (ImageView) convertView.findViewById(R.id.country_icon); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } this.cur.moveToPosition(position); holder.txtTitle.setText(this.cur.getString(this.cur.getColumnIndex("CountryID"))); holder.txtDate.setText(this.cur.getString(this.cur.getColumnIndex("Country"))); Flag =(this.cur.getString(this.cur.getColumnIndex("CountryImage"))); Flag=Flag.trim(); // Set country icon usign File path try { String imgFilePath = ASSETS_DIR +""+Flag; Bitmap bitmap = BitmapFactory.decodeStream(this.context.getResources().getAssets().open(imgFilePath)); holder.countryIcon.setImageBitmap(bitmap); } catch (IOException e) { e.printStackTrace(); } return convertView; } } </code></pre>
    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.
 

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