How to show actionbar on higher Android version and menu in lower Android version?
Is this possible with one APK file.?
The version of the device that I am testing APK file is on Jelly Bean.
Here is the code that I tried.
Manifest.xml has:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
in My activity, I am calling this.
public class HomeActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
setupActionBar();
...
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME
| ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().show();
}
}
My menu.xml looks like this
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_refresh"
android:orderInCategory="100"
android:showAsAction="always"
android:icon="@drawable/ic_refresh"
android:title="Refresh"/>
</menu>
Please suggest me. Thank you.