Wednesday, 15 January 2014

eclipse - Should use android:showAsAction when not using the appcompat library -



eclipse - Should use android:showAsAction when not using the appcompat library -

i have weird problem, using menu.xml file in android application this:

<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:compat="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/action_refresh" android:orderincategory="100" android:title="@string/action_refresh" android:icon="@drawable/toc" compat:showasaction="always"/> </menu>

and working well, days ago updating eclipse lastly version, , after that, app:showasaction="always" shows error:

should utilize android:showasaction when not using appcompat library , after action bar icons moved overflow bar , not showing in action bar @ all.

anyway, appcompat library parent of base of operations style. should resolve that?

you need 3 things-

add these 3 things xmlns:tools="schemas.android.com/tools" tools:context="com.example.sample.youractivity" xmlns:yourapp="http://schemas.android.com/apk/res-auto" <menu> tag

along usual xmlns:android="http://schemas.android.com/apk/res/android"

add yourapp:showasaction="ifroom" <item>.

finally, clean project via project -> clean...

the lastly step solved me. cleaning project (they can dirty sometimes)

this final code looks like:

<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="schemas.android.com/tools" tools:context="com.example.sample.youractivity" xmlns:yourapp="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/action_share" android:orderincategory="100" android:title="share" android:icon="@drawable/ic_share_white" yourapp:showasaction="ifroom" /> </menu>

android eclipse android-actionbar appcompat

No comments:

Post a Comment