I need to add a checkbox to this listview, I have the row.xml setup with a textview/chrono/checkbox. Do I have to show the checkbox in my baseadapter extending? Also why does that getSystemService() error out on me?
package com.walkarchdev.tasktracker;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Chronometer;
import android.widget.TextView;
public class TTAdapterView extends BaseAdapter {
public View v;
public TTAdapterView(Context context){
super();
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
this.v = convertView;
if(v==null){
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
}
TextView task = (TextView)v.findViewById(R.id.textView1);
Chronometer time = (Chronometer)v.findViewById(R.id.chronometer1);
//Checkbox complete = (Checkbox)v.findViewById(R.id.checkBox1);
return v;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
}
getSystemService()is a method onContext. Save the context passed as an argument in the constructor and use it to call thegetSystemService()methodIf you intend to use the states of checkbox then you must store it in a variable in order to monitor the checked states