I want to add action bar on top of my activity. How to add action bar in the following layout. And I want to create action bar for API level less than 11. Can anyone provide me tutorial reference of that.
Layout-
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/buddha"
android:gravity="center"
android:orientation="vertical"
>
<View
android:id="@+id/top1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@null"
android:gravity="center"
android:layout_weight="5"
/>
<Button
android:id="@+id/hist"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="#73000000"
android:gravity="center"
android:textSize="@dimen/btxt"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:layout_weight="1"
android:text="@string/his"
/>
<View
android:id="@+id/top2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@null"
android:gravity="center"
android:layout_weight=".10"
/>
<Button
android:id="@+id/typ"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:background="#73000000"
android:textSize="@dimen/btxt"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:layout_weight="1"
android:text="@string/typ"
/>
<View
android:id="@+id/top3"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@null"
android:gravity="center"
android:layout_weight=".10"
/>
<Button
android:id="@+id/ben"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="1"
android:textSize="@dimen/btxt"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:background="#73000000"
android:text="@string/ben"
/>
<View
android:id="@+id/top4"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@null"
android:gravity="center"
android:layout_weight=".10"
/>
<Button
android:id="@+id/exit"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:gravity="center"
android:textSize="@dimen/btxt"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:background="#73000000"
android:layout_weight="1"
android:text="@string/exit"
/>
<View
android:id="@+id/top41"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="@null"
android:gravity="center"
android:layout_weight=".10"
/>
</LinearLayout>
setup your project to appcompat v7 library for reference see http://developer.android.com/guide/topics/ui/actionbar.html#Adding
and
The compatibility library has support for actionbar that works on old devices. This blog post explains how to use it and provides code samples: http://android-developers.blogspot.co.uk/2013/08/actionbarcompat-and-io-2013-app-source.html
You need to create a
menu.xml
files inres/menu
folder.Then, you need to inflate and add it in your actionbar using
onCreateOptionsMenu()
method in yourMainActivity
class.And since you want to use action bar on API level less than 11, there are two popular options
ActionBarSherlock tutorial: Adding ActionBarSherlock to Your Project