Robby Pond
Robby Pond

Reputation: 73484

Is it possible to set an android icon from a drawable in a separate jar?

I want to set a menu option icon for a drawable that is in another jar inside an xml file.

<item android:id="@+id/my_location"
      android:title="My Location"
      android:icon="@+drawable/my_location">

Instead of drawable/my_location have something like com.somelib.R.drawable.someDrawable.

I can set this in onCreateOptionsMenu but was just wondering if it could be done via the xml file.

Upvotes: 2

Views: 632

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006964

I want to set a menu option icon for a drawable that is in another jar inside an xml file.

Drawable resources cannot go in JARs. You are welcome to store images in a JAR and deal with them outside of the resource framework.

I can set this in onCreateOptionsMenu but was just wondering if it could be done via the xml file.

No, because, again, images in a JAR file are not resources, defined as images in res/drawable-*/ in your project. Sorry!

Upvotes: 3

Related Questions