android.content.res.Resources $ NotFoundException:资源ID#0x7f020278 [英] android.content.res.Resources$NotFoundException: Resource ID #0x7f020278

查看:89
本文介绍了android.content.res.Resources $ NotFoundException:资源ID#0x7f020278的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android编程的新手,尝试在当前位置使用地图,但是当我看到logcat时,发现以下错误:

I'm new to Android programing, and am trying to use a map with my current location, but when I look at logcat, I see the following error:


RunTimeException android.content.res.Resources $ NotFoundException:
资源ID#0x7f020278 at
android.content.res.Resources.getValue(Resources.java:2329)at
android.content.res.Resources.startRC(Resources.java:1057)at
android.app.ActivityThread $ mRunnable.run(ActivityThread.java:2477)at
java.lang.Thread .run(Thread.java:818)07-15 18:40:16.624 13526-13526
com.example.paul.mapasxavo E / ViewRootImpl:sendUserActionEvent()mView
== null

RunTimeException android.content.res.Resources$NotFoundException: Resource ID #0x7f020278 at android.content.res.Resources.getValue(Resources.java:2329) at android.content.res.Resources.startRC(Resources.java:1057) at android.app.ActivityThread$mRunnable.run(ActivityThread.java:2477) at java.lang.Thread.run(Thread.java:818) 07-15 18:40:16.624 13526-13526 com.example.paul.mapasxavo E/ViewRootImpl﹕ sendUserActionEvent() mView == null

MapsActiviy类中的Java代码为:

The Java code in the MapsActiviy class is:

public class MapsActivity extends FragmentActivity {
    // Might be null if Google Play services APK is not available.
    private GoogleMap mMap; 
    private SensorManager sensorManager;
    private Sensor accelerometer;
    LocationManager locationManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        setUpMapIfNeeded();
    }

    @Override
    protected void onResume() {
        super.onResume();
        setUpMapIfNeeded();
    }

    private void setUpMap() {
        LOCATION_SERVICE locationManager = 
            (LocationManager)getSystemService(LOCATION_SERVICE);
        Criteria criteria = new Criteria();
        String provider = locationManager.getBestProvider(criteria, true);
        Location location = locationManager.getLastKnownLocation(provider);
        mMap.clear();
        LatLng currentPosition = new LatLng(location.getLatitude(), location.getLongitude());
        mMap.addMarker(new MarkerOptions().position(currentPosition).title("Yo"));

        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentPosition, 13));
        mMap.setMyLocationEnabled(true);
        Log.v("MapaActivity", currentPosition.toString());
    }
}

这是XML文件

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:id="@+id/map"
    tools:context="com.example.paul.mapasxavo.MapsActivity"
    android:name="com.google.android.gms.maps.SupportMapFragment" />

我做错了什么?

推荐答案

我得到了同样的错误,但我通过这种简单的方式解决了它!检查xml布局,如果它看起来像 abc.xml(xlarge-mdpi),那么只需删除它并在默认布局文件夹中创建一个新的abc.xml,确保它不应该像之前那样。
如果答案可以帮助你。投票!
开心编码!

I got same error but I solved it by this simple way !. check your xml layout if it looks like abc.xml(xlarge-mdpi) then simply delete it and create new one abc.xml in default layout folder make sure it should not like previous one. if answer helps you. vote up! happy coding!

这篇关于android.content.res.Resources $ NotFoundException:资源ID#0x7f020278的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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