Intsab Haider
Intsab Haider

Reputation: 3571

ActionBar Up Icon Doesn't work

In an application my one activity showing abnormal behavior its Actionbar Up Button doesn't works.. Its an Activity ProductListActivity in oncreate i put these two lines

ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);

in manifest.xml

  <activity
            android:name=".activity.ProductsListActivity"
            android:label="@string/title_activity_products_list"
            android:screenOrientation="portrait"
            android:theme="@style/CustomActivityTheme" >
             <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.ef.umall.activity.HomeActivity" />
        </activity>

But Up button is not working My Min SDK is 16 and Max 19

Upvotes: 2

Views: 56

Answers (1)

ThMBc
ThMBc

Reputation: 804

starting from api 16 the up navigation was introduced and needs to be set in the activity tag. To ensure compatibility with appcompat for versions below 16 the meta-data tag is used, so you need this line for it to work:

<activity
        android:name=".activity.ProductsListActivity"
        android:label="@string/title_activity_products_list"
        android:screenOrientation="portrait"

        android:parentActivityName="com.ef.umall.activity.HomeActivity"

        android:theme="@style/CustomActivityTheme" >
         <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.ef.umall.activity.HomeActivity" />
</activity>

Upvotes: 1

Related Questions