0

我有一个用于列表视图的光标适配器。在这个适配器中,我们有以下代码。该项目是一个 ImageView ,我正在尝试使其可见并将其设置为来自数据库的值中的图像名称。正如您从我的 logcat 中看到的那样,当它为空时,当它被填充时它仍然失败。我假设我需要将字符串转换为位图对象或可绘制对象。任何人?

日志猫:

06-21 09:32:38.020: I/PROJECTCARUSO(10061): is_stamp: observation_4
06-21 09:32:38.020: I/PROJECTCARUSO(10061): is_stamp2: observation_4
06-21 09:32:38.020: I/System.out(10061): resolveUri failed on bad bitmap uri: observation_4
06-21 09:32:38.101: I/PROJECTCARUSO(10061): is_stamp: null
06-21 09:32:38.101: I/PROJECTCARUSO(10061): is_stamp3: null
06-21 09:32:38.101: I/System.out(10061): resolveUri failed on bad bitmap uri: 





if (columnIndex == cursor.getColumnIndex(StatusData.KEY_CHARTING_STAMPS)) {
             String is_stamp = cursor.getString(columnIndex);
             Log.i("PROJECTCARUSO", "is_stamp0: " + is_stamp);
             if (is_stamp != null) {
                 if (is_stamp.equalsIgnoreCase("")){
                        // set the visibility of the view to GONE
                     Log.i("PROJECTCARUSO", "is_stamp1: " + is_stamp);
                        view.setVisibility(View.INVISIBLE);
                    }else {
                        Log.i("PROJECTCARUSO", "is_stamp2: " + is_stamp);
                        view.setVisibility(View.VISIBLE);
                    }
             } else {
                 Log.i("PROJECTCARUSO", "is_stamp3: " + is_stamp);
                 view.setVisibility(View.INVISIBLE);
             }
4

1 回答 1

0
Drawable is_stamp_draw = getResources().getDrawable(getResources().getIdentifier("drawable/" + is_stamp, null, getActivity().getPackageName())); 
view.setBackground(is_stamp_draw);
于 2013-06-21T15:30:11.490 回答