Reputation: 4663
Having a drawable i would like to find the identifier
Layout
<TextView
...
android:drawablePadding="5dp"
android:drawableLeft="@drawable/account_lock"
/>
Activity
...
TextView tv = ...;
Drawable d = tv.getCompoundDrawables()[0];
int id = d.???????
i have looked at getResources().getIdentifier(name, defType, defPackage)
but i do not think it helps me to find it;
Upvotes: 0
Views: 134
Reputation: 1961
This is how I've done it. I don't know whether you need it to be in a subfolder of res as I have, though.
//In this example, I'm getting an id from the res/raw folder.
int id = *activity.this*.getApplicationContext().getResources().getIdentifier(*filename*, "raw", *packagename*);
Upvotes: 0