Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an example. Read the comments in the getView(...) of the adapter provided below.</p> <hr> <pre><code>class TaskObject { private int pid; private String processName; private boolean toKill; ///getters/setters public boolean isToKill() { return toKill; } public void setToKill(boolean toKill) { this.toKill = toKill; } ................................ } </code></pre> <hr> <pre><code>class TaskListAdapter extends BaseAdapter { private static final String TAG = "adapter"; ArrayList&lt;TaskObject&gt; list; Context context; public TaskListAdapter(Context context) { Log.d(TAG, "created new task list adapter"); this.context = context; if (list == null) { list = new ArrayList&lt;TaskObject&gt;(); } } public void addTask(TaskObject taskObject) { list.add(taskObject); } public void clearTasks() { list.clear(); Log.d(TAG, "list size:" + list.size()); this.notifyDataSetChanged(); } public int getCount() { return list.size(); } public TaskObject getItem(int position) { return list.get(position); } public long getItemId(int position) { return position; } public View getView(final int position, View convertView, ViewGroup parent) { RelativeLayout rl = new RelativeLayout(context); TextView textPid = new TextView(context); textPid.setText(Integer.toString(getItem(position).getPid())); TextView textName = new TextView(context); textName.setText(getItem(position).getProcessName()); /////Here is your and it will set back your checked item after scroll CheckBox chckKill = new CheckBox(context); if(getItem(position).isToKill()) { chckKill.setChecked(true); } //////////////////////////////////////////////////////////////////// chckKill.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //is chkIos checked? if (((CheckBox) v).isChecked()) { getItem(position).setToKill(true); } } }); chckKill.setTag(getItem(position).getPid()); /////////NOT LAYOUTED USE LAYOUT rl.addView(chckKill); rl.addView(textName); rl.addView(textPid); return rl; } </code></pre> <hr> <p>hope it helps abit.</p>
    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