Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 列出从SQLite db读取数据时未显示的项目_Android_Sqlite_Listview_Android Arrayadapter - Fatal编程技术网

Android 列出从SQLite db读取数据时未显示的项目

Android 列出从SQLite db读取数据时未显示的项目,android,sqlite,listview,android-arrayadapter,Android,Sqlite,Listview,Android Arrayadapter,在我的android应用程序中,我试图通过列表适配器显示列表,数据来自SQLite db。然而,列表项没有显示,尽管我认为一切都很好。 这是我显示列表的代码 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.store_list_activity);

在我的android应用程序中,我试图通过列表适配器显示列表,数据来自SQLite db。然而,列表项没有显示,尽管我认为一切都很好。 这是我显示列表的代码

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.store_list_activity);
        float storeId = 1;
//Storedb is my data adapter class of SQLite
        StoreDb storelist = new StoreDb(this);
        storelist.open();
        ArrayList arraylist= storelist.getStoreName(storeId);
           adapter= new ArrayAdapter<String>(this, R.layout.store_list_style, arraylist);
           medicine_List= (ListView) findViewById (R.id.list);
           medicine_List.setAdapter(adapter);
           medicine_List.setOnItemClickListener(this);

    }
@覆盖
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.store\u list\u活动);
float-storeId=1;
//Storedb是我的SQLite数据适配器类
StoreDb storelist=新的StoreDb(此);
storelist.open();
ArrayList ArrayList=storelist.getStoreName(storeId);
adapter=新的ArrayAdapter(这个,R.layout.store\u list\u样式,arraylist);
medicine_List=(ListView)findViewById(R.id.List);
药物列表。设置适配器(适配器);
药物列表。SetonicmClickListener(本);
}
这就是从SQLite读取数据的方法

public ArrayList getStoreName(long storeId) {
        ArrayList<String> array_list = new ArrayList<String>();
        String[] column2 = new String[] { AREA_PREV_ID, STORE_NAME };
        Cursor res = ourDatabase.query(DATABASE_TABLE2, column2, AREA_PREV_ID + "=" + storeId, null, null, null, null);
        int istore = res.getColumnIndex(STORE_NAME);
        if (res != null) {
            res.moveToFirst();
          while(res.isAfterLast() == false){
              String s = res.getString(istore);
          array_list.add(s);
          res.moveToNext();
          }
        }
        return array_list;
    }
public ArrayList getStoreName(长storeId){
ArrayList数组_list=新建ArrayList();
String[]column2=新字符串[]{AREA\u PREV\u ID,STORE\u NAME};
Cursor res=ourDatabase.query(数据库表2,第2列,区域\u PREV\u ID+“=”+storeId,null,null,null,null);
int-istore=res.getColumnIndex(存储区名称);
如果(res!=null){
res.moveToFirst();
while(res.isAfterLast()==false){
字符串s=res.getString(istore);
数组_列表。添加(s);
res.moveToNext();
}
}
返回数组_列表;
}

谁能帮我一下我做错了什么!提前感谢您

在每个阶段添加日志记录,并检查您的logcat输出是否存在任何异常。尝试使用android.R.layout.simple\u list\u item\u 1而不是R.layout.store\u list\u style检查arrayList arrayList=storelist.getStoreName(storeId)的大小;在android.R.layout.simple_list_项上更改它_1@NaveenTamrakar好的,让我来做!