1

我有以下代码,我正在使用 sherlockfragments。

 map = ((SupportMapFragment) getActivity().getSupportFragmentManager()
            .findFragmentById(R.id.map)).getMap();

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="450px"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>

我收到错误:

android.view.InflateException: Binary XML file line #94: Error inflating class fragment

4

4 回答 4

4

已解决 感谢大家的建议。

<Meta> Tag should be in <Application> Tag.
于 2013-08-01T11:28:15.003 回答
1

我不确定这是否是正确的答案,但尝试将您的片段放在ViewGroup中,它可能会解决问题。

于 2013-08-01T08:38:18.767 回答
1

尝试删除 getActivity()..

map = ((SupportMapFragment) getActivity().getSupportFragmentManager()
        .findFragmentById(R.id.map)).getMap();

只需尝试通过以下方式进行更改:

map = ((SupportMapFragment) getSupportFragmentManager()
        .findFragmentById(R.id.map)).getMap();

它确实对我有用......希望它也对你有用

于 2013-08-01T09:32:03.113 回答
1

试试你用这个:

private GoogleMap MAP;  

FragmentManager myFM = getSupportFragmentManager();  
       SupportMapFragment myMAPF = (SupportMapFragment) myFM  
                 .findFragmentById(R.id.map);

MAP = myMAPF.getMap();

你也必须改变它:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="450px"
      android:name="com.google.android.gms.maps.SupportMapFragment"/>

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="450px"
      class="com.google.android.gms.maps.SupportMapFragment"/>
于 2013-08-01T11:52:40.230 回答