Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It all works like a charm, mainly thanks to Jake's great work on ActionBarSherlock</p> <p>Here are the steps I followed:</p> <ol> <li>Create a SherlockMapFragment class in your actiobarsherlock library project. I simply made a copy of SherlockFragment because I also needed support for <code>setHasOptionsMenu(true)</code></li> <li>The activity extends SherlockFragmentActivity (as usual)</li> <li>The fragment extends the newly created SherlockMapFragment</li> <li>ActionBarSherlock requires the new <code>google-play-services_lib</code> library</li> <li>Your project requires the ActionBarSherlock library. No need to include the google-play-services again, or to build against Google API.</li> <li>As mentionned by Graham, you have to drop support for API 7 devices: <code>&lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt;</code></li> </ol> <p>And here's some code for a more detailed explanation:</p> <p><strong>SherlockMapFragment</strong></p> <pre><code>package com.actionbarsherlock.app; 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; 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; 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; } } </code></pre> <p><strong>The activity:</strong></p> <pre><code>public class MainActivity extends SherlockFragmentActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } </code></pre> <p><strong>The activity XML layout:</strong></p> <pre><code>&lt;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" &gt; &lt;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" /&gt; &lt;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" /&gt; &lt;/FrameLayout&gt; </code></pre> <p><strong>The map fragment:</strong></p> <pre><code>public class MapFragment extends SherlockMapFragment { private GoogleMap mMap; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = super.onCreateView(inflater, container, savedInstanceState); mMap = getMap(); return root; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload