11
I have .png images in my res/drawable-hdpi/delete.png I want to add it as icon to my menu item.
I used:
delete.xml
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/deletebutton">
</bitmap>
Menu activity_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/create"
android:showAsAction="always"
android:title="@string/createTask"/>
<item
android:id="@+id/delete"
android:showAsAction="always"
android:icon="@drawable/delete"
android:title="@string/deleteTask" />
</menu>
But its not working.
I removed the xml file and tried directly to load the image here is the log file.
04-02 17:46:50.887: E/AndroidRuntime(11957): FATAL EXCEPTION: main
04-02 17:46:50.887: E/AndroidRuntime(11957): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.devicecontrolpanel/com.example.devicecontrolpanel.Main}: android.content.res.Resources$NotFoundException: Resource ID #0x7f020008
04-02 17:46:50.887: E/AndroidRuntime(11957): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2205)
04-02 17:46:50.887: E/AndroidRuntime(11957): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2240)
04-02 17:46:50.887: E/AndroidRuntime(11957): at android.app.ActivityThread.access$600(ActivityThread.java:139)
04-02 17:46:50.887: E/AndroidRuntime(11957): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
04-02 17:46:50.887: E/AndroidRuntime(11957): at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 17:46:50.887: E/AndroidRuntime(11957): at android.os.Looper.loop(Looper.java:156)
04-02 17:46:50.887: E/AndroidRuntime(11957): at android.app.ActivityThread.main(ActivityThread.java:4