I am trying to implement ActionBarSherlock in my project.Adding menu/action items to the action bar is working on 2.1 but not in my nexus4, not in 4.0.3 emulator too. The problem is the function onCreateOptionsMenu(Menu menu)
never gets called in my device but gets called in 2.1 and hence no action items are shown in action bar in my phone.
Following is a part of manifest where theme is set.
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light.DarkActionBar" >
Following is menu.xml file:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_item_call"
android:showAsAction="always"
android:title="Call"/>
<item
android:id="@+id/menu_item_share"
android:showAsAction="always"
android:title="Share"/>
<item
android:id="@+id/menu_item_save"
android:showAsAction="always"
android:title="Save"/>
</menu>
Following is relevant part of the activity.
//other imports
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.Window;
public class SelectCategories extends SherlockActivity implements
OnClickListener {
//other code
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
//return true; also has no effect
}
}
I have been trying to solve this issue and it has been several hours but couldnt. Please help me. Thank you in advance.
Finally Figured out the issue.
Infact, I was trying to change existing project to use action bar. And Main thing is that the project uses TabActivity which is deprecated. Since ActionBarSherlock do not provide its custom implementation, I thought that it should be used as is. And that was my mistake. After removing tabactivity, I can see the menus in both versions.
Thank you alot for all who tried to help.