/ABSherlock-Demos/src/com/actionbarsherlock/sample/demos/CollapsibleActionItem.java
Java | 46 lines | 24 code | 6 blank | 16 comment | 1 complexity | 64f457238df970f0639fc397a00c0d43 MD5 | raw file
1/*
2 * Copyright (C) 2012 Scott Kennedy
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.actionbarsherlock.sample.demos;
17
18import android.os.Bundle;
19import android.widget.TextView;
20
21import com.actionbarsherlock.app.SherlockActivity;
22import com.actionbarsherlock.view.Menu;
23import com.actionbarsherlock.view.MenuItem;
24
25public class CollapsibleActionItem extends SherlockActivity {
26 @Override
27 public boolean onCreateOptionsMenu(Menu menu) {
28 //Used to put dark icons on light action bar
29 boolean isLight = SampleList.THEME == R.style.Theme_Sherlock_Light;
30
31 menu.add("Search")
32 .setIcon(isLight ? R.drawable.ic_search_inverse : R.drawable.ic_search)
33 .setActionView(R.layout.collapsible_edittext)
34 .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
35
36 return true;
37 }
38
39 @Override
40 protected void onCreate(Bundle savedInstanceState) {
41 setTheme(SampleList.THEME); //Used for theme switching in samples
42 super.onCreate(savedInstanceState);
43 setContentView(R.layout.text);
44 ((TextView)findViewById(R.id.text)).setText(R.string.collapsible_content);
45 }
46}