@TianCheng 2016-04-28 10:05 采纳率: 100%
浏览 1205
已采纳

关于安卓的SQLite问题

大神好,小弟学习时遇到这个问题,不知道该怎么解决
图片说明
我是想要在一个Fragment页面里动态加载ListView,写了一个自定义的Adapter
在 onActivityCreated里面写了
adapter=new FragmentRecordAdapter(this,start, end);
listView_data.setAdapter(adapter);

在Adapter里面写了
public class FragmentRecordAdapter extends BaseAdapter {
AddDAO2 adao;
FragmentRecord f;
Cursor cursor;

public FragmentRecordAdapter(FragmentRecord fragmentRecord, String start,String end) {
    // TODO Auto-generated constructor stub
    this.f=fragmentRecord;
    adao = new AddDAO2(f);
    cursor = adao.queryAllDetail(start, end);
}

@Override
public int getCount() {
    return cursor.getCount();
}

@Override
public Object getItem(int position) {
    return null;
}

@Override
public long getItemId(int position) {
    return 0;
}

@SuppressLint("InflateParams") 
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    View view = null;
    if (convertView != null) {
    view = convertView;//复用了回收的view 只需要直接作内容填充的修改就好了
    } else {
    view = LayoutInflater.from(null).inflate(R.layout.f_record_detail_lv_item_2, null);
    //没有供复用的view 按一般的做法新建view
    TextView tv01 = (TextView) view.findViewById(R.id.tv01);
    TextView tv02 = (TextView) view.findViewById(R.id.tv02);
    TextView tv03 = (TextView) view.findViewById(R.id.tv03);
    TextView tv04 = (TextView) view.findViewById(R.id.tv04);
    cursor.moveToPosition(position);
    tv01.setText(cursor.getString(cursor.getColumnIndex(ActionConstants.record.SportType)));
    tv02.setText(cursor.getString(cursor.getColumnIndex(ActionConstants.record.FitnessPart)));
    tv03.setText(cursor.getString(cursor.getColumnIndex(ActionConstants.record.FitnessContent)));
    tv04.setText(cursor.getString(cursor.getColumnIndex(ActionConstants.record.Time)));
    }
    return view;
}

}
在AddDAO2里面:
public class AddDAO2 {
SQLiteDatabase db;

public AddDAO2(FragmentRecord f) {
    // TODO Auto-generated constructor stub
    db = new ActionDataHelper(null, f).getWritableDatabase();
}

想不明白该怎么解决,求大神帮助!谢谢

  • 写回答

2条回答

  • xSeeker~ 2016-04-28 10:31
    关注

    我看你的log,错误的地方已是insert语句add附近,add是SQLite的关键字,你用add作为表名,存在歧义,建议将表名换成合适的

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn