Some tweaks to the loader API demo.

Unfinished, but checkpointing.

Change-Id: Ib832a6915847302e8bbb23c6cf111c932fdacabf
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index 82469d1..48b7f23 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -254,6 +254,7 @@
         <activity android:name=".app.FragmentLayout$DialogActivity" />
 
         <activity android:name=".app.FragmentListCursorLoader"
+                android:theme="@android:style/Theme.WithActionBar"
                 android:label="@string/fragment_list_cursor_loader">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -270,6 +271,7 @@
         </activity>
 
         <activity android:name=".app.FragmentMenu"
+                android:theme="@android:style/Theme.WithActionBar"
                 android:label="@string/fragment_menu">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
diff --git a/samples/ApiDemos/res/drawable/magnifying_glass.png b/samples/ApiDemos/res/drawable/magnifying_glass.png
new file mode 100755
index 0000000..2592ae0
--- /dev/null
+++ b/samples/ApiDemos/res/drawable/magnifying_glass.png
Binary files differ
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentListCursorLoader.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentListCursorLoader.java
index 6889a08..c095692 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentListCursorLoader.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentListCursorLoader.java
@@ -16,16 +16,23 @@
 
 package com.example.android.apis.app;
 
+import com.example.android.apis.R;
+
 import android.app.Activity;
 import android.app.ListFragment;
 import android.app.LoaderManager;
+import android.content.Context;
 import android.content.CursorLoader;
 import android.content.Loader;
 import android.database.Cursor;
 import android.os.Bundle;
 import android.provider.ContactsContract.Contacts;
 import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
+import android.view.inputmethod.InputMethodManager;
 import android.widget.ListAdapter;
 import android.widget.ListView;
 import android.widget.SimpleCursorAdapter;
@@ -49,6 +56,8 @@
 
     public static class CursorLoaderListFragment extends ListFragment
             implements LoaderManager.LoaderCallbacks<Cursor> {
+        MenuItem mSearchMenu;
+        
         @Override
         public void onActivityCreated(Bundle savedInstanceState) {
             super.onActivityCreated(savedInstanceState);
@@ -57,12 +66,34 @@
             // application this would come from a resource.
             setEmptyText("No phone numbers");
             
+            // We have a menu item to show in action bar.
+            setHasOptionsMenu(true);
+            
             // Prepare the loader.  Either re-connect with an existing one,
             // or start a new one.
             getLoaderManager().initLoader(0, null, this);
         }
 
         @Override
+        public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+            mSearchMenu = menu.add("Search");
+            mSearchMenu.setIcon(R.drawable.magnifying_glass);
+            mSearchMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+        }
+
+        @Override
+        public boolean onOptionsItemSelected(MenuItem item) {
+            if (item == mSearchMenu) {
+                InputMethodManager imm = (InputMethodManager)getActivity()
+                        .getSystemService(Context.INPUT_METHOD_SERVICE);
+                imm.showSoftInput(getActivity().getCurrentFocus(), 0);
+                return true;
+            } else {
+                return super.onOptionsItemSelected(item);
+            }
+        }
+
+        @Override
         public void onListItemClick(ListView l, View v, int position, long id) {
             Log.i("FragmentComplexList", "Item clicked: " + id);
         }
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentMenu.java b/samples/ApiDemos/src/com/example/android/apis/app/FragmentMenu.java
index e928fa7..68e2446 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentMenu.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/FragmentMenu.java
@@ -8,6 +8,7 @@
 import android.os.Bundle;
 import android.view.Menu;
 import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.CheckBox;
@@ -89,8 +90,8 @@
 
         @Override
         public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-            menu.add("Menu 1a");
-            menu.add("Menu 1b");
+            menu.add("Menu 1a").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+            menu.add("Menu 1b").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
         }
     }
 
@@ -107,7 +108,7 @@
 
         @Override
         public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-            menu.add("Menu 2");
+            menu.add("Menu 2").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
         }
     }
 }