Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom SimpleCursorAdapter error
    primarykey
    data
    text
    <p>I have ListView in my Activity, and custom SimpleCursorAdapter. Custom SimpleCursorAdapter looks like this.</p> <pre><code>public class MySimpleCursorAdapter extends SimpleCursorAdapter { private Activity activity; private Cursor cursor; public MySimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, Activity activity) { super(context, layout, c, from, to); this.activity = activity; this.cursor = c; } @Override public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) view = View.inflate(this.activity, com.tour.R.layout.third_level_list_item, null); cursor.moveToPosition(position); String hotelName=cursor.getString(cursor.getColumnIndexOrThrow(TodoDbAdapter.KEY_HOTEL)); String stars = cursor.getString(cursor.getColumnIndexOrThrow(TodoDbAdapter.KEY_ROW_STARS)); int numberOfStars = Integer.parseInt(stars); TextView hotel = (TextView) view.findViewById(com.tour.R.id.hotel); if (hotel != null) hotel.setText(hotelName); ImageView[] images = new ImageView[5]; images[0] = (ImageView) view.findViewById(com.tour.R.id.slika1); images[1] = (ImageView) view.findViewById(com.tour.R.id.slika2); images[2] = (ImageView) view.findViewById(com.tour.R.id.slika3); images[3] = (ImageView) view.findViewById(com.tour.R.id.slika4); images[4] = (ImageView) view.findViewById(com.tour.R.id.slika5); for (int i = 0; i &lt; numberOfStars; i++) images[i].setVisibility(View.VISIBLE); return view; } </code></pre> <p>}</p> <p>CustomSimpleCursor adapter is setted as list adapter.</p> <p>Code works great, hotel name is ok, stars are ok, but problem is that after scrolling list some time, every hotel gets 5 stars, and I know that it`s true.</p> <p>Any help how to manage number of stars in that listView from database. Thanks.</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.
 

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