新しいフラグメントに Google マップを追加しようとしています。しかし、私はこのエラーが発生します:
08-16 16:58:37.334: E/AndroidRuntime(15409): 致命的な例外: メイン 08-16 16:58:37.334: E/AndroidRuntime(15409): android.view.InflateException: バイナリ XML ファイル行 #2: エラークラスフラグメントを膨張させるandroid.view.LayoutInflater.inflate(LayoutInflater.java:467) で
フラグメントを起動するコードは次のとおりです。
Fragment fragment1 = new MapsFragment();
//fragment.setArguments(arguments);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
fragmentTransaction.replace(R.id.content_frame, fragment1);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
そして、これが私の MapsFragment のコードです:
import com.rss.main.MainActivity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class MapsFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LayoutInflater mInflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View view = (View) mInflater.inflate(R.layout.maps_view, null);
// MainActivity.setShareButtonToVisible();
// MainActivity.setElevatorButtonToInVisible();
return view;
}
@Override
public void onDestroyView() {
MainActivity.setShareButtonToInVisible();
super.onDestroyView();
}
}
そして、これが私の maps_view.xml のコードです:
<?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="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
問題はどこだ ?
ありがとう