hashmap中的TextView无法在android中显示数据

时间:2013-09-23 06:06:36

标签: android listview hashmap

我只想问一些关于hashmap的事情。目前我正在将数据库中的数据显示到hasmap中。首先,当我在数据库中保存信息时,当您检查listview(hashmap)时,我可以完美地看到我保存的所有信息。但是当我关闭应用程序并再次打开它然后检查列表视图时,它无法显示其内容(数据库中所有已保存的信息)。我的logcat很清楚,我没有收到任何错误,但是我没能得到正确的输出。

下面显示了使用数据库中的数据填充列表视图的方法。

private void fillData(Cursor cursor)
{
    Log.i("goes", "filldata");
    int pendingData = cursor.getCount();
    int [] pendingDataIds = new int[pendingData];
    for (int i = pendingData-1, j = 0;  i > -1; j++, i--)
    {
        if (cursor.moveToFirst() == true)
            cursor.moveToPosition(i);

        pendingDataIds[j] = cursor.getInt(cursor.getColumnIndex(Constants.REPORT_ID));
        Log.i("current id", String.valueOf(pendingDataIds[j]));
    }
    try{
        arraylistPendingData = new ArrayList<HashMap<String,String>>();
        HashMap<String,String> hashmap = null;

        for (int k = 0; k < pendingDataIds.length; k++)
        {
            if(pendingDataIds[k] != 0)
            {
                Cursor cursorPendingData = databaseHandler.getPendingData(pendingDataIds[k]);
                String reportId = cursorPendingData.getString(cursorPendingData.getColumnIndex(Constants.REPORT_CODE));
                String infocode = cursorPendingData.getString(cursorPendingData.getColumnIndex(Constants.REPORT_INFOTYPECODE));
                String InformationType = "";
                if(infocode.equals("-"))
                {
                    InformationType = "";
                }else{
                    Cursor cursorInfoCode = databaseHandler.getInfoName(reportId);
                    InformationType = cursorInfoCode.getString(cursorInfoCode.getColumnIndex(Constants.INFORMATIONTYPE_NAME));
                }
                Log.i("INFORMATIONTYPE_NAME",InformationType );
                Log.i("REPORT_CODE",cursorPendingData.getString(cursorPendingData.getColumnIndex(Constants.REPORT_CODE)) );
                Log.i("REPORT_DATEOBSERVED", cursorPendingData.getString(cursorPendingData.getColumnIndex(Constants.REPORT_DATEOBSERVED)) );

                if (reportId != null && !reportId.equals(""))
                {
                    hashmap = new HashMap<String,String>();
                    hashmap.put(Constants.REPORT_CODE, cursorPendingData.getString(cursorPendingData.getColumnIndex(Constants.REPORT_CODE)));
                    hashmap.put(Constants.REPORT_DATEOBSERVED, cursorPendingData.getString(cursorPendingData.getColumnIndex(Constants.REPORT_DATEOBSERVED)));
                    hashmap.put(Constants.INFORMATIONTYPE_NAME, InformationType);
                    hashmap.put(Constants.ACTION, "Details");
                    hashmap.put(Constants.EDIT, "Edit");
                    hashmap.put(Constants.REPORT_ID, cursorPendingData.getString(cursorPendingData.getColumnIndex(Constants.REPORT_ID)));
                    arraylistPendingData.add(hashmap);


                }
            }
        }
        Log.d("arraylistPendingData", String.valueOf(arraylistPendingData.size()));
        simpleAdapterPendingData = new CustomSimpleAdapterWithCheckbox(S_9th_ISubmit.this, arraylistPendingData, R.layout.pendingreportattributecell, Constants.PENDINGDATA_ATTRIBUTE_KEYS, Constants.PENDINGDATA_ATTRIBUTES_VIEWS, true);
        lv_iScan.setAdapter(simpleAdapterPendingData);

0 个答案:

没有答案