请问这个怎么添加!有大神指点下吗?

qq_28484955 2019-07-29 12:18:38
{ ListView list; SQLiteDatabase ptlm; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { putongliangmadatabase data=new putongliangmadatabase(getActivity()); ptlm=data.getWritableDatabase(); Cursor cursor= ptlm.query("putongliangma",null,"putong2haoma", new String[]{},null,null,null); while(cursor.moveToNext()){ SimpleCursorAdapter adpter=new SimpleCursorAdapter( getActivity (),R.layout.putong1_item,cursor,new String[]{"putong2haoma", "putong2dangqian","putong2shangchi","putong2zuida"}, new int[]{R.id.putong1_haomax,R.id.putong1_dangqianx,R.id.putong1_shangchix,R.id.putong1_zuidax}, SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); list=(ListView) getView() .findViewById(R.id.putong1_haomalist); list.setAdapter(adpter); } return inflater.inflate(R.layout.putong1_fragment, null); } public void ptlmtj(View v){ ArrayList<String> List=new ArrayList<>(); ContentValues values=new ContentValues(); for (int a=1; a <= 12; a++) { for (int b=1; b <= 12; b++) { if (a != b ) { if (a < b) { List.add("\r\n"+a+ "," + b); } } } } values.put("putong2haoma",List); values.put("putong2dangqian",0); values.put("putong2shangchi",0); values.put("putong2zuida",0); } }
...全文
168 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
头发还没秃a 2019-07-31
  • 打赏
  • 举报
回复
引用 3 楼 qq_28484955 的回复:
[quote=引用 2 楼 风轻云淡v10的回复:]Contenvalues只能存储基本类型的数据,像string,int之类的,不能存储对象或者List这种东西
谢谢!那要存储list里的东西怎么办?[/quote] 想办法转为String型
qq_28484955 2019-07-31
  • 打赏
  • 举报
回复
引用 2 楼 风轻云淡v10的回复:
Contenvalues只能存储基本类型的数据,像string,int之类的,不能存储对象或者List这种东西
谢谢!那要存储list里的东西怎么办?
qq_28484955 2019-07-29
  • 打赏
  • 举报
回复
values.put("putong2haoma",List);是错误的
头发还没秃a 2019-07-29
  • 打赏
  • 举报
回复
Contenvalues只能存储基本类型的数据,像string,int之类的,不能存储对象或者List这种东西

80,349

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧