Back to project page AnyadsTodos.
The source code is released under:
GNU General Public License
If you think the Android project AnyadsTodos listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.dlacours.anyadstodos; /*from w w w.j a v a 2 s . c o m*/ import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; public class TaskListAdapter extends ArrayAdapter<Task> { /*This is the adapter for the main tasklist. * It monitors checkmark changes*/ private LayoutInflater inflater; public TaskListAdapter(Context context, TaskList taskList) { super(context, R.layout.single_task, taskList.getUnarchived()); inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public Task getItem(int position) { return TaskListController.getUnarchList().getUnarchived().get(position); } @Override public View getView(int position, View convertView, ViewGroup parent) { final int finalpos = position; if (convertView == null){ convertView = inflater.inflate(R.layout.single_task, null); } CheckBox checkbox = (CheckBox) convertView.findViewById(R.id.taskcheckbox); checkbox.setText(getItem(position).getTask()); checkbox.setChecked(getItem(position).getChecked()); checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked){ getItem(finalpos).setChecked(true); if(!getItem(finalpos).getRemoved()){ SummariesActivity.CheckedSum(1); SummariesActivity.UncheckedSum(-1); } } else { getItem(finalpos).setChecked(false); if(!getItem(finalpos).getRemoved()){ SummariesActivity.CheckedSum(-1); SummariesActivity.UncheckedSum(1); } } } }); return convertView; } }