Ramotion/circle-menu-android

android.content.res.Resources$NotFoundException

Akshay-Katariya opened this issue · 2 comments

I am setting icons from java file as follows

for (int i = 0; i < bCount; i++)
        {
            icons.add(getIconInt());
            colors.add(Color.rgb(rnd.nextInt(255), rnd.nextInt(255), rnd.nextInt(255)));
        }

        final CircleMenuView menu = new CircleMenuView(this, icons, colors);

whereas my getIconInt looks as follows

int getIconInt()
    {
        int iconId = 0;
        PackageManager pm = getPackageManager();
        String pkg = "example.package.name";

        try
        {
            ApplicationInfo ai = pm.getApplicationInfo(pkg, 0);
            iconId = ai.icon;
        }
        catch (PackageManager.NameNotFoundException e) {

        }
        return iconId;
    }

my getIconInt() is working properly i tried to log my function and it returns me this = 2130837968

So please help me setting Drawable as icons or tell me whats wrong here

OR
How can I customize CircleMenuView class and achieve the following if possible

I've edited the code so that we can add drawables instead of bitmaps. I think, it's more convenient
especially when using libraries such as com.mikepenz:iconics-core. Drop me a message if you're interested or if we can merge my code.

Hello, @Akshay-Katariya. Look closely inside Color.rgb() method. It returns a color-int from red, green, blue float components. If you also look inside CircleViewConstructor, which you're using, you'll see the docs, stating:
/**
* Constructor for creation CircleMenuView in code, not in xml-layout.
* context current context, will be used to access resources.
* icons buttons icons resource ids array. Items must be @DrawableRes.
* colors buttons colors resource ids array. Items must be @DrawableRes.
*/

Your mistake is trying to send color ints to constructor, while it waits for color res ids.