与osmdroid-的Andr​​oid 3.0.7运行时,不能访问资源的图标 [英] Cannot access resource icons when running with osmdroid-android-3.0.7

查看:86
本文介绍了与osmdroid-的Andr​​oid 3.0.7运行时,不能访问资源的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始显示的地图的一对夫妇使用osmdroid-的Andr​​oid 3.0.7库标记一个简单的地图活动。在code下的旧版本(1.10)工作。我收到以下错误: 02-03 15:14:30.574:E / AndroidRuntime(10277):java.lang.IllegalArgumentException异常:产生的原因未找到资源:marker_default.png

I am trying to start a simple map activity that displays a map an a couple of markers using osmdroid-android-3.0.7 library. The code worked under an older version (1.10). I am getting the following error: 02-03 15:14:30.574: E/AndroidRuntime(10277): Caused by: java.lang.IllegalArgumentException: Resource not found: marker_default.png

当我解压的jar文件,我可以看到的图标列表中的顶级目录,其中一人的确是marker_default.png。这是code中的片段:

When I unzipped the jar file I can see a list of icons in the top level directory and one of them is indeed marker_default.png. This is the snippet of the code:

public class MapDisplay extends Activity 
{
    private MapView mapView;
    private ResourceProxy resProxy;
    private ItemizedOverlay<OverlayItem> locationOverlay;

    public void onCreate(final Bundle savedState) 
    {
        super.onCreate(savedState);

        resProxy = new DefaultResourceProxyImpl(getApplicationContext());

        final RelativeLayout rl = new RelativeLayout(this); 

        mapView = new MapView(this, 256);
        mapView.setBuiltInZoomControls(true);
        mapView.getController().setZoom(6);
             mapView.getController().setCenter(new GeoPoint(51500000, 5400000));
                  rl.addView(mapView, new RelativeLayout.LayoutParams 
                      (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

        final ArrayList<OverlayItem> items = new ArrayList<OverlayItem>();
        OverlayItem o1 = new OverlayItem("Location 1", "Comment", 
                       new GeoPoint(51500000, 5400000));
                  o1.setMarker(getResources().getDrawable(R.drawable.icall));
        items.add(o1);
        OverlayItem o2 = new OverlayItem("Location 2", "Comment", 
                       new GeoPoint(52500000, 5500000));
                  o2.setMarker(getResources().getDrawable(R.drawable.icall));
        items.add(o2);
                  this.locationOverlay = new ItemizedIconOverlay<OverlayItem>(items,
                    new ItemizedIconOverlay.OnItemGestureListener<OverlayItem>() 
                    {
                        @Override
                        public boolean onItemSingleTapUp(final int index, 
                                      final OverlayItem item) 
                        {
                                Toast.makeText(
                                                MapDisplay.this,
                                                "Item '" + item.mTitle + "' (index=" + index
                                                                + ") got single tapped up", Toast.LENGTH_LONG).show();
                                return true; // We 'handled' this event.
                        }

                        @Override
                        public boolean onItemLongPress(final int index, 
                          final OverlayItem item) 
                        {
                                Toast.makeText(
                                                MapDisplay.this,
                                                "Item '" + item.mTitle + "' (index=" + index
                                                                + ") got long pressed", Toast.LENGTH_LONG).show();
                                return false;
                        }
                }, resProxy);
           this.mapView.getOverlays().add(this.locationOverlay);
           mapView.invalidate();
                this.setContentView(rl);
    }
}

当我试图用一个简单的叠加,因此没有设置任何图标标记,然后我得到了同样的错误,除非它指的person.png(该图标也是解压后的jar文件)。 我已经添加了通过项目属性的jar文件中,可以访问API就好了。

When I tried to use a simple overlay and therefore did not set any icons for the marker then I got the same error except it referred to person.png (that icon is also in the unzipped jar file). I have added the jar file via project properties and can access the api just fine.

我为什么不能访问的图标?

Why can't I access the icons?

顺便说一句,我试着在图标复制到我的项目,但我得到了同样的错误。

BTW, I tried to copy the icons into my project but I got the same error.

谢谢,阿尼亚

推荐答案

我有同样的问题 - 在最新的罐子(3.0.8)的问题已修复

I had the same problem - in the latest jar (3.0.8) the issue is fixed.

这篇关于与osmdroid-的Andr​​oid 3.0.7运行时,不能访问资源的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆