Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backgroud 为color时 报 NotFoundException: Resource ID #0x0 #20

Open
IAskWind opened this issue Apr 25, 2016 · 2 comments
Open

backgroud 为color时 报 NotFoundException: Resource ID #0x0 #20

IAskWind opened this issue Apr 25, 2016 · 2 comments

Comments

@IAskWind
Copy link

页面设置:
android:tag="skin:skin_colorPrimary:background"
android:background="@color/skin_colorPrimary"
报错:
No package identifier when getting value for resource number 0x00000000
...........................
at com.zhy.changeskin.attr.SkinAttrType$1.apply(SkinAttrType.java:23)
指向:
Drawable drawable = getResourceManager().getDrawableByName(resName);
没有找到资源

@yilylong
Copy link

修改SkinAttrType 添加对color 的支持

 BACKGROUD("background") {
    @Override
    public void apply(View view, String resName) {
        Drawable drawable = getResourceManager().getDrawableByName(resName);
        // TODO ZHL 添加一种background 设置成color的情况
        if (null!=drawable){
            view.setBackgroundDrawable(drawable);
        }else{
            int color = getResourceManager().getColor(resName);
            if(color==-1)
                return ;
            view.setBackgroundColor(color);
        }
    }
}

@hoangsondev
Copy link

"No package identifier when getting value for resource number 0x00000000" - This is warning when id resource equal 0. If you want not to out warning you can check id resource, for example:

public Drawable getDrawableByName(String name) {
    try {
        int id = mResources.getIdentifier(name, "drawable", mPluginPackageName);
        return id == 0 ? getDrawable(name) : mResources.getDrawable(id);
    } catch (Exception e) {
        return getDrawable(name);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants