我正在尝试使用下面显示的自定义适配器将ContentValues
加载到ListView
。
public class LazyAdapter extends BaseAdapter {
private Activity activity;
private ContentValues values = new ContentValues();
private static LayoutInflater inflater = null;
public LazyAdapter(Activity a, ContentValues v) {
activity = a;
values = v;
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if(convertView == null)
vi = inflater.inflate(R.layout.list_item, null);
TextView name = (TextView) vi.findViewById(R.id.list_item_text_name);
TextView reg_no. = (TextView) vi.findViewById(R.id.list_item_text_reg_no);
ImageView image_thumb = (ImageView) vi.findViewById(R.id._list_item_image);
ContentValues student = new ContentValues();
/** here I am trying to get a single student data from the ContentValues **/
student = values.get(position); //Getting the error on this line
//Setting values into the ListView
name.setText(variant.getAsString(StudenttContract.Column.NAME));
reg_no.setText(variant.getAsString(StudentContract.Column.REG_NO));
imageLoader.DisplayImage(variant.getAsString(StudentContract.Column.thumb_url), image_thumb);
return vi;
}
问题是我收到错误:The method get(String) in the type ContentValues is not applicable for the arguments (int)
在这一行:
student = values.get(position);
我如何解决这个或我还能做些什么来从ContentValues
获取一名学生的数据。