cleve yeo
cleve yeo

Reputation: 103

Action Bar Does not Split

i have search through and tried all the solution posted but my action bar still does not split. The extra items get overflow to the overflow menu and i have not idea why. Please help me with it. thanks!!!!!!!

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.apptutorial"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" 
        android:uiOptions="splitActionBarWhenNarrow">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <meta-data
            android:name="android.support.UI_OPTIONS"
            android:value="splitActionBarWhenNarrow"
        />
    </activity>
</application>

MainActivity.java

package com.example.apptutorial;

import android.support.v7.app.*;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

@SuppressWarnings("deprecation")
public class MainActivity extends ActionBarActivity {


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

}

menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.apptutorial.MainActivity" >

<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:title="@string/action_settings"
    app:showAsAction="never"/>

<item
    android:id="@+id/phone"
    android:title="@string/phone"
    android:icon="@drawable/ic_action_call"
    app:showAsAction="ifRoom|withText"
    />

<item
    android:id="@+id/computer"
    android:title="@string/computer"
    android:icon="@drawable/ic_action_computer"
    app:showAsAction="ifRoom|withText"
    />

<item
    android:id="@+id/email"
    android:title="@string/email"
    android:icon="@drawable/ic_action_mail"
    app:showAsAction="ifRoom|withText"
    />

<item
    android:id="@+id/video"
    android:title="@string/video"
    android:icon="@drawable/ic_action_video"
    app:showAsAction="ifRoom|withText"
    />

Upvotes: 0

Views: 192

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006584

The split action bar is not supported by the native action bar on Android 5.0+ or by the appcompat-v7 action bar backport. You are using appcompat-v7; hence, you do not have a split action bar.

Either redesign your app to not need the split action bar, or arrange to put your own Toolbar at the bottom of your UI that contains the items that you want to have in there.

Upvotes: 2

Related Questions