舊版本的應用程序使用MapView
。我改變了SupportMapFragment
錯誤。我知道如何解決這個問題。谷歌地圖SupportMapFragment錯誤中的片段
過程:com.test.app,PID:7847
android.view.InflateException:二進制XML文件行#14:錯誤 充氣類片段
XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
片段
public class MyFragment extends Fragment implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
LocationListener {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_map, null);
SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
buildGoogleApiClient();
return rootView;
}
的build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'se.emilsjolander:stickylistheaders:2.5.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
//compile 'com.google.firebase:firebase-messaging:10.2.0'
}
應用上下文來使用這些工具的片段指向正確的活動:上下文屬性 –
我都用過,但沒有奏效@Bradley威爾遜 –
使用getActivity()getSupportFragmentManager()代替 –