simple cursor adapter requires minimum api 11 issue

不羁的心 提交于 2020-02-01 05:18:07

问题


I am working on a app , in which i require to populate list view from the database. I am getting compatibility issue in following code

   dataAdapter = new SimpleCursorAdapter(
    this, R.layout.eventlisting, 
    cursor, 
    columns, 
    to,
    0);

It requires min api level 11 , mine is 8. Is there any alternative for this to make this code work on api 8 as well. Can i use support library?


回答1:


Try the SimpleCursorAdapter from the support class. It is used like the API 11+ version and it is already backwards compatible.

You have to download the Support Library , so you only need to change the import Like This way :

import android.support.v4.widget.SimpleCursorAdapter;



回答2:


For Backword compatibility you can download support library and make your Code working.

to add support library

Right Click your Project -> android tools -> add support library.

then again

Right Click your Project -> android tools -> fix project properties.

and then clean build your project.after that you will be able to import SimpleCursorAdapter class in your application.hope it will help.



来源:https://stackoverflow.com/questions/14291006/simple-cursor-adapter-requires-minimum-api-11-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!