Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.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 从drawable文件夹读取图像时出错_Android_Json_Imageview - Fatal编程技术网

Android 从drawable文件夹读取图像时出错

Android 从drawable文件夹读取图像时出错,android,json,imageview,Android,Json,Imageview,我正在执行从json读取数据并在listview中显示数据的活动。我想通过检查某些条件将图像静态添加到listview。但它返回的错误如下: 07-03 14:50:48.398: E/BitmapFactory(1106): Unable to decode stream: java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory) 07-03 14:50:48.408: E/BitmapFactory(1106

我正在执行从json读取数据并在listview中显示数据的活动。我想通过检查某些条件将图像静态添加到listview。但它返回的错误如下:

07-03 14:50:48.398: E/BitmapFactory(1106): Unable to decode stream: java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
07-03 14:50:48.408: E/BitmapFactory(1106): Unable to decode stream: java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
07-03 14:50:48.438: E/BitmapFactory(1106): Unable to decode stream: java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
07-03 14:50:48.458: E/BitmapFactory(1106): Unable to decode stream: java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
07-03 14:50:48.468: E/BitmapFactory(1106): Unable to decode stream: java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
07-03 14:50:48.998: E/BitmapFactory(1106): Unable to decode stream: java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
07-03 14:50:49.008: E/BitmapFactory(1106): Unable to decode stream: java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
07-03 14:50:49.018: E/BitmapFactory(1106): Unable to decode stream: java.io.FileNotFoundException: /: open failed: EISDIR (Is a directory)
main活动

protected void onPostExecute(List<List<HashMap<String, String>>> result) {
            ArrayList<LatLng> points = null;
            PolylineOptions lineOptions = null;
            MarkerOptions markerOptions = new MarkerOptions();
            String distance = "";
            Spanned instruction;
            String turns = "";
            String duration = "";
            String str = "";
            int t = 0;
            if (result.size() < 1) {
                Toast.makeText(getBaseContext(), "No Points",
                        Toast.LENGTH_SHORT).show();
                return;
            }

            // Traversing through all the routes
            for (int i = 0; i < result.size(); i++) {

                points = new ArrayList<LatLng>();
                lineOptions = new PolylineOptions();

                // Fetching i-th route
                List<HashMap<String, String>> path = result.get(i);

                // Fetching all the points in i-th route
                for (int j = 0; j < path.size(); j++) {
                    HashMap<String, String> point = path.get(j);

                    instruction = Html.fromHtml((String) point
                            .get("html_instructions"));
                    str = instruction.toString();
                    // Log.i("str", str);
                    distance = (String) point.get("distance_text");
                    turns = (String) point.get("maneuver");

                    double lat = Double.parseDouble(point.get("lat"));
                    double lng = Double.parseDouble(point.get("lng"));
                    LatLng position = new LatLng(lat, lng);

                    points.add(position);
                    HashMap<String, String> map1 = new HashMap<String, String>();
                    map1.put("instruction", str);
                    if (turns == "turn-left") {
                        map1.put("img", Integer.toString(img[8]));
                    }
                    else if (turns == "turn-right") {
                        map1.put("img", Integer.toString(img[9]));
                    } else if (turns == "fork-right") {
                        map1.put("img", Integer.toString(img[1]));
                    } else if (turns == "turn-slight-right") {
                        map1.put("img", Integer.toString(img[11]));
                    } else if (turns == "turn-slight-left") {
                        map1.put("img", Integer.toString(img[10]));
                    } else if(turns == "fork-left"){
                         map1.put("img", Integer.toString(img[0]));
                         }
                    else if (turns == "uturn-right") {
                        map1.put("img", Integer.toString(img[7]));
                    } else if(turns == ""){
                         map1.put("img", Integer.toString(img[2]));
                    }
                    // else if(turns == "ramp-left"){
                    // map1.put("img", Integer.toString(img[1]));
                    // }

                    //map1.put("distance", distance);
                    // map1.put("turns", Integer.toString(t));
                    oslist.add(map1);
                }

                // Adding all the points in the route to LineOptions
                lineOptions.addAll(points);
                lineOptions.width(2);
                lineOptions.color(Color.RED);

            }

            // Log.i("list", oslist.toString());
             String[] from = { "img","instruction" };

                // Ids of views in listview_layout
                int[] to = { R.id.flag,R.id.txt};

                SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), oslist, R.layout.activity_main, from, to);

            list.setAdapter(adapter);

            // tvDistanceDuration.setText("Distance:"+distance +
            // ", Duration:"+duration);

            // Drawing polyline in the Google Map for the i-th route
            map.addPolyline(lineOptions);
受保护的void onPostExecute(列表结果){
ArrayList points=null;
PolylineOptions lineOptions=null;
MarkerOptions MarkerOptions=新MarkerOptions();
字符串距离=”;
跨距指令;
字符串变为“”;
字符串持续时间=”;
字符串str=“”;
int t=0;
if(result.size()<1){
Toast.makeText(getBaseContext(),“无点”,
吐司。长度(短)。show();
返回;
}
//穿越所有路线
对于(int i=0;i
试试这个:

setImageDrawable(getActivity().getResources().getDrawable(R.drawable.image))