diff --git a/samples/Support7Demos/AndroidManifest.xml b/samples/Support7Demos/AndroidManifest.xml
index 3e2ef99b0..f358bf772 100644
--- a/samples/Support7Demos/AndroidManifest.xml
+++ b/samples/Support7Demos/AndroidManifest.xml
@@ -213,6 +213,15 @@
+
+
+
+
+
+
+
@@ -271,6 +280,15 @@
+
+
+
+
+
+
+
diff --git a/samples/Support7Demos/res/layout/action_bar_action_mode.xml b/samples/Support7Demos/res/layout/action_bar_action_mode.xml
new file mode 100644
index 000000000..d498fda95
--- /dev/null
+++ b/samples/Support7Demos/res/layout/action_bar_action_mode.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/Support7Demos/res/layout/toolbar_action_mode.xml b/samples/Support7Demos/res/layout/toolbar_action_mode.xml
new file mode 100644
index 000000000..e2a1dd81e
--- /dev/null
+++ b/samples/Support7Demos/res/layout/toolbar_action_mode.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/Support7Demos/res/values/strings.xml b/samples/Support7Demos/res/values/strings.xml
index 7e8fc872b..1a56e0978 100644
--- a/samples/Support7Demos/res/values/strings.xml
+++ b/samples/Support7Demos/res/values/strings.xml
@@ -57,6 +57,7 @@
Handling in onOptionsItemSelected avoided
AppCompat/Action Bar/Navigation Drawer Toggle
AppCompat/Action Bar/Preferences
+ AppCompat/Action Bar/Action Mode
AppCompat/Widgets/Buttons
AppCompat/Widgets/Spinners
AppCompat/Widgets/Text Input
@@ -129,6 +130,7 @@
AppCompat/Toolbar/Toolbar as Action Bar
AppCompat/Toolbar/Toolbar Display Options
AppCompat/Toolbar/Toolbar Fragment ViewPager
+ AppCompat/Toolbar/Action Mode
AppCompat/Dialog/Dialog Usage
My great dialog
@@ -173,5 +175,6 @@
Search...
Sorted List
Add New Item
+ Start Action Mode
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarActionMode.java b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarActionMode.java
new file mode 100644
index 000000000..6edf59357
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/ActionBarActionMode.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.supportv7.app;
+
+import com.example.android.supportv7.R;
+
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.view.ActionMode;
+import android.support.v7.widget.SearchView;
+import android.text.TextUtils;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * This demonstrates idiomatic usage of an action mode.
+ */
+public class ActionBarActionMode extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.action_bar_action_mode);
+
+ findViewById(R.id.btn_start_action_mode).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ startActionMode();
+ }
+ });
+ }
+
+ private void startActionMode() {
+ startSupportActionMode(new ActionMode.Callback() {
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ mode.getMenuInflater().inflate(R.menu.actions, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ Toast.makeText(ActionBarActionMode.this,
+ "Action Mode item clicked:" + item.getTitle(), Toast.LENGTH_SHORT).show();
+ return true;
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+ }
+ });
+ }
+
+}
diff --git a/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarActionMode.java b/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarActionMode.java
new file mode 100644
index 000000000..3977048ca
--- /dev/null
+++ b/samples/Support7Demos/src/com/example/android/supportv7/app/ToolbarActionMode.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.supportv7.app;
+
+import com.example.android.supportv7.R;
+
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.view.ActionMode;
+import android.support.v7.widget.Toolbar;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Toast;
+
+/**
+ * This demonstrates idiomatic usage of an action mode with a Toolbar.
+ */
+public class ToolbarActionMode extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.toolbar_action_mode);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ findViewById(R.id.btn_start_action_mode).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ startActionMode();
+ }
+ });
+ }
+
+ private void startActionMode() {
+ startSupportActionMode(new ActionMode.Callback() {
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ mode.getMenuInflater().inflate(R.menu.actions, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ Toast.makeText(ToolbarActionMode.this,
+ "Action Mode item clicked:" + item.getTitle(), Toast.LENGTH_SHORT).show();
+ return true;
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+ }
+ });
+ }
+
+}