Note that there are some explanatory texts on larger screens.

plurals
  1. POwhat have I done to my TextViews?
    primarykey
    data
    text
    <p>OK, so I have a cursor adapter that I cobbled together from various source and mostly seems to work -except my name fields. I have two checkboxes on a listview for each name but my names are all coming out the same (the first name)</p> <p>Anyone spot the problem I've create? Your help would be appreciated.</p> <pre><code>public class MyDataAdapter extends SimpleCursorAdapter { private Cursor c; private Context context; private ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;(); private ArrayList&lt;Boolean&gt; itemCheckedHere = new ArrayList&lt;Boolean&gt;(); private ArrayList&lt;Boolean&gt; itemCheckedLate = new ArrayList&lt;Boolean&gt;(); private ArrayList&lt;Integer&gt; itemCheckedIdx = new ArrayList&lt;Integer&gt;(); int idxCol; int idx; // itemChecked will store the position of the checked items. public MyDataAdapter(Context context, int layout, Cursor c, String[] from, int[] to) { super(context, layout, c, from, to); this.c = c; this.context = context; c.moveToFirst(); for (int i = 0; i &lt; c.getCount(); i++) { itemCheckedHere.add(i, false); // initializes all items value with false itemCheckedLate.add(i, false); // initializes all items value with false } } public View getView(final int pos, View inView, ViewGroup parent) { TextView studentName; ImageView studentPhoto; if (inView == null) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); inView = inflater.inflate(R.layout.show_attendance, null); } final CheckBox cBoxH = (CheckBox) inView.findViewById(R.id.attend); final CheckBox cBoxL = (CheckBox) inView.findViewById(R.id.late); // set up name field studentName = (TextView) inView.findViewById(R.id.stuname); if (studentName != null) { int index = c.getColumnIndex(gradeBookDbAdapter.KEY_NAME); String name = c.getString(index); studentName.setText(name); } cBoxH.setOnClickListener(new OnClickListener() { public void onClick(View v) { CheckBox cb = (CheckBox) v.findViewById(R.id.attend); if (cb.isChecked()) { itemCheckedHere.set(pos, true); // do some operations here } else if (!cb.isChecked()) { itemCheckedHere.set(pos, false); // do some operations here } } }); cBoxL.setOnClickListener(new OnClickListener() { public void onClick(View v) { CheckBox cb = (CheckBox) v.findViewById(R.id.late); if (cb.isChecked()) { itemCheckedLate.set(pos, true); // do some operations here } else if (!cb.isChecked()) { itemCheckedLate.set(pos, false); // do some operations here } } }); cBoxH.setChecked(itemCheckedHere.get(pos)); // this will Check or Uncheck the cBoxL.setChecked(itemCheckedLate.get(pos)); // this will Check or Uncheck the // CheckBox in ListView // according to their original // position and CheckBox never // loss his State when you // Scroll the List Items. return inView; } </code></pre>
    singulars
    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.
    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