asses resouces from another apk for widget(like theme apk)

Posted by Diljeet on Stack Overflow See other posts from Stack Overflow or by Diljeet
Published on 2013-10-30T07:19:18Z Indexed on 2013/10/30 9:54 UTC
Read the original article Hit count: 279

asses resouces from another apk for widget(like theme apk)

Hello i made a theme with drawables and strings, i can access the theme's resources by following commands

String packagename="com.....";
Resources res = context.getPackageManager().getResourcesForApplication(packagename);
int strid = res.getIdentifier(packagename+":string/"+name, "string", packagename);
int drawableid = res.getIdentifier(packagename+":drawable/"+name, "drawable", packagename);

String name = res.getString(resid);
Bitmap bmp = BitmapFactory.decodeResource(res, resid);
//or
Drawable dr=res.getDrawable(resid);

I can get the drawables, but i don't know how to set the drawables in xml to a widget. I only can set setImageViewResource(int viewid, int resId);

So i am asking that how to access xml resources from another apk and set widget drawables from it.

I want to access a resource like this from another theme apk, but i can only access the drawable(so can't use it for widgets)

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
        android:drawable="@drawable/wplayh" />
    <item android:drawable="@drawable/wplay" />
</selector>

© Stack Overflow or respective owner

Related posts about android

Related posts about android-widget