Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is android:showAsAction deprecated?

Tags:

java

android

I have a question about "android:showAsAction". I have a book for Android and in that book (IMO it's not up to date, but most things are valid) they use

    android:showAsAction

To display menu item on action bar (menu is created in Fragment). I'm using the Android Studio. Compile SDK version is set to API 19 (KitKat). I'm firing it on my LG G2, which has Android 4.4 on board.

I'm asking if this is deprecated, because Android Studio tells me:

     Should use app:showAsAction with the appcompat library with xmlns:app="http://schemas.android.com/apk/res-auto" less... (Ctrl+F1) 
     When using the appcompat library, menu resources should refer to the showAsAction in the app: namespace, not the android: namespace.  
     Similarly, when not using the appcompat library, you should be using the android:showAsAction attribute.

I assume that appcompat library is the Support library. However I'm not using it at all, because I don't need backward compatibility.

Also, when I will switch to the app:showAsAction and I will add proper app:xmlns, then my action item in my Action Bar is not visible. When I'm switching back to android:showAsAction, then the icon is visible.

I'm wondering what is wrong in my code, should I use app:showAsAction or should I use android:showAsAction ?

Best ragards

like image 463
Ma Kro Avatar asked Jan 25 '15 19:01

Ma Kro


1 Answers

It's not deprecated you just have to use app: instead of android: when you are working with the ActionBar from the Support Library. The meaning of all those options is the same. They just can not use android: from within the Support Library because it's a standalone library. You can't really use android: if you are working with the support Action Bar.

like image 105
Alexander Kulyakhtin Avatar answered Oct 05 '22 02:10

Alexander Kulyakhtin