问题描述
|
我需要在此列表视图中添加一个复选框,我具有带有textview / chrono / checkBox的row.xml设置。我是否需要在我的baseadapter中扩展复选框?另外,为什么那getSystemService()出错了?
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()
我错了吗?
getSystemService()
是Context
的一种方法。将作为参数传递的上下文保存在构造函数中,并使用其调用getSystemService()
方法
Do I have to show the checkbox in my baseadapter extending?
如果打算使用复选框的状态,则必须将其存储在变量中以监视选中的状态
,如果不手动使用适配器中的复选框状态,则向下滚动时,ListView中的复选框状态会出现问题。
您打给getSystemService
是什么错误?