Reputation: 671
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;
}
}
Upvotes: 0
Views: 1531
Reputation: 3006
Without manually working with checkbox state in your adapter you will have the problem with checkboxes states in your ListView when scroll it down.
What kind of error do you have calling getSystemService
?
Upvotes: 0
Reputation: 13582
why does that getSystemService() error out on me?
getSystemService()
is a method on Context
. Save the context passed as an argument in the constructor and use it to call the getSystemService()
method
Do I have to show the checkbox in my baseadapter extending?
If you intend to use the states of checkbox then you must store it in a variable in order to monitor the checked states
Upvotes: 1