SherlockActivtiyBar を使用して、フラグメント内で Google Android Map v2 を開発しようとしています。
このエラーがあります:
04-12 10:01:26.830: E/AndroidRuntime(1089): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.it.michele.ab.map/it.michele.prova.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
手伝って頂けますか?
私が間違っていることは何ですか?
ここに私のEclipseプロジェクト:
http://www.michelepierri.it/project.zip
これは私のコードです:
SherlockMapFragment.java
package com.actionbarsherlock.app;
import android.app.Activity;
import android.support.v4.app.Watson.OnCreateOptionsMenuListener;
import android.support.v4.app.Watson.OnOptionsItemSelectedListener;
import android.support.v4.app.Watson.OnPrepareOptionsMenuListener;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.internal.view.menu.MenuItemWrapper;
import com.actionbarsherlock.internal.view.menu.MenuWrapper;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.google.android.gms.maps.SupportMapFragment;
public class SherlockMapFragment extends SupportMapFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
private SherlockFragmentActivity mActivity;
public SherlockFragmentActivity getSherlockActivity() {
return mActivity;
}
@Override
public void onAttach(Activity activity) {
if (!(activity instanceof SherlockFragmentActivity)) {
throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
}
mActivity = (SherlockFragmentActivity)activity;
super.onAttach(activity);
}
@Override
public void onDetach() {
mActivity = null;
super.onDetach();
}
@Override
public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
//Nothing to see here.
}
@Override
public final void onPrepareOptionsMenu(android.view.Menu menu) {
onPrepareOptionsMenu(new MenuWrapper(menu));
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
//Nothing to see here.
}
@Override
public final boolean onOptionsItemSelected(android.view.MenuItem item) {
return onOptionsItemSelected(new MenuItemWrapper(item));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
//Nothing to see here.
return false;
}
}
MainActivity.java
package it.michele.prova;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import android.os.Bundle;
import android.app.Activity;
//import android.view.Menu;
import com.actionbarsherlock.view.*;
import com.example.it.michele.ab.map.R;
import com.example.it.michele.ab.map.R.layout;
import com.example.it.michele.ab.map.R.menu;
//import com.google.android.gms.maps.*;
public class MainActivity extends SherlockFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, (android.view.Menu) menu);
return true;
}
}
activity_main.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/fragment_map"
android:name=".ui.fragments.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="tag_fragment_map" />
<fragment
android:id="@+id/fragment_help"
android:name=".ui.fragments.HelpFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:tag="tag_fragment_help" />
</FrameLayout>