I'm using ActionBarSherlock and HoloEverywhere in this project. The Main.xml is pretty simple and looks like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/action_settings"
android:orderInCategory="100"
android:showAsAction="ifRoom|withText"
android:title="#string/action_info_settings"
android:icon="#android:drawable/ic_menu_customsettings"/>
</menu>
I have ic_menu_customsettings.png in drawable-mdpi, drawable-hdpi, and drawable-xhdpi. I'm getting the following error:
Error: No resource found that matches the given name (at 'icon' with value '#android:drawable/ic_menu_customsettings').
Am I supposed to do something more than put the png files in those folders to make them accessible by the ActionBar?
The correct line is:
android:icon="#drawable/ic_menu_customsettings"/>
Related
I am new to android and am following this one tutorial pdf guide.
so far ive not found many unfixable errors.
except when i tried creating a folder in manifest of type menu and created menu_main.xml.
i get attribute is missing from the android name space prefix and a bunch other errors like unexpected text found in layout..
here is the code i pasted from the book. to the menu_main.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Our add icon will have its own button -->
<item android﹕id="#+id/action_add"
android﹕icon="#drawable/ic_add_white_24dp"
android﹕title="#string/action_add"
app﹕showAsAction="ifRoom" />
</menu>
Turns out all I had to do was delete the colons and re-type them because the spacing between the android:something was a little out of normal.
I am following step by step instructions shared on development platform of google http://developer.android.com/training/basics/actionbar/index.html
But some how due to some reason I am not seeing ic_action_search.png on Menu bar in my simulator, though it is imported and copied on drawable-hdpi.
Listing down all options tried till now (using eclipse IDE):
Import image ic_action_search.png
Don't import image but copy it directly on folder
Size of image, I have copied it directly from Android_Design_Icons.zip suggested at https://developer.android.com/design/downloads/index.html
Recompile project by "Clean"
Deleting res in bin folder
Deleting R.java in gen folder
Creating whole project altogether again
Changing option android:showAsAction to "never", "always", "ifRoom"
Placing .png file at right place
Not using .jpg only .png
Using Support library
Using lower case to define file names
Added following to menu tag,
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.actionbar.MainActivity"
Added follwoing to item tag
android:actionViewClass="android.widget.SearchView"
My main_activity_actions.xml looks like,
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="never" />
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" /></menu>
.... but still I cant see search image getting loaded up in menu bar. Though settings icon shows the action_search value defined in string.xml
I am not using Support Library Setup as of now, and android:minSdkVersion="11"
android:targetSdkVersion="19"
I need to show this, as there is something wrong here and as i go further I still cant load any other image. Please advise
You need to change the showAsAction as always or ifRoom to show the action icons in the menu bar.
If you set it to never , it will not be shown as an action menu. It will only show in PopupMenu
Change
android:showAsAction="never"
to
android:showAsAction="always"
append this line in your menu tag xmlns:yourapp="http://schemas.android.com/apk/res-auto"
and append these two lines in item tag
yourapp:actionViewClass="android.widget.SearchView"
yourapp:showAsAction="always"
i.e. use this layout
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<!-- Search / will display always -->
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:actionViewClass="android.widget.SearchView"
yourapp:actionViewClass="android.widget.SearchView"
yourapp:showAsAction="always"
android:showAsAction="always"/>
All, Forgive me I just began to learn development of Android, It is the first time I used the ActionBar in my Android application. Firstly.
I was following the tutorial to add the resource of ActionBar to project. But the IDE alert me the resource can't be found. please help to review my current setup. thanks.
I had downloaded and upziped all the Icons. and copy all the icons under the res/drawable folder.
and I add a xml file named main_activity_actions.xml under the folder res/menu which content shows below.
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- Search, should appear as action button -->
<item android:id="#+id/action_search"
android:icon="#drawable/Core_Icons/unstyled/hdpi/ic_action_search"
android:title="#string/action_search"
android:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="never" />
</menu>
Could someone please tell me why IDE can't find the icon ic_action_search.png? thanks.
Unfortunately the resource folders do not support directory hierarchies (sub-folders), so you will need to move all icons to the parent folder (drawable).
Then reference it like this: android:icon="#drawable/ic_action_search"
https://code.google.com/p/android/issues/detail?id=2018
I am beginning android development and I am having problems making an action bar. Basically I am following some code form online and I am getting an error saying I do not have an icon:
error: Error: No resource found that matches the given name (at 'icon' with value '#drawable/ic_menu_search').
I did some research and thought my problem was I did not have all the extras downloaded from the android SDK. But after downloading all the extras it didnt work. I know I could just find the icon and download it, but I do not want to have to download all the icons individually, therefore I think I am missing something. My xml file I am getting the error with looks like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="#string/action_settings"/>
<item android:id="#+id/menu_search"
android:title="#string/menu_search"
android:icon="#drawable/ic_menu_search"
android:showAsAction="ifRoom|collapseActionView"
android:actionViewClass="android.widget.SearchView" />
</menu>
this is under menu>main.xml
If you want to use the android icon, you should add the android prefix after #. Change
#drawable/ic_menu_search
in
#android:drawable/ic_menu_search
#drawable looks inside the res/drawable* folder of your app. If you want to access to the android resources. strings/drawable/id you have to put the android prefix after the #. with that prefix you will access to the android.R class not to your.R class
I have this menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/refresh" android:title="Actualizar" android:icon="#android:drawable/ic_menu_refresh"></item>
<item android:title="Sair" android:id="#+id/exit" android:icon="#android:drawable/ic_menu_close_clear_cancel"></item></menu>
and i'm getting this error:
Error: Resource is not public. (at 'icon' with value '#android:drawable/ic_menu_refresh').
Why the resource is not public? I have this icon in other apps and worked.
Maybe it's protected. In some API level, some icons are allowed to use, some are not. You can try ic_menu_home ic_menu_preferences ic_menu_help
Some links to refer:
http://groups.google.com/group/android-developers/browse_thread/thread/dabbe62aa1b54c13
android: resource not found