Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8972445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:13:12+00:00 2026-06-15T18:13:12+00:00

Is it possible to receive the resource-ids being kept by a as an int[]

  • 0

Is it possible to receive the resource-ids being kept by a as an int[] programmatically without referring to the resource-class R?

<declare-styleable name="com_facebook_login_view">
    <attr name="confirm_logout" format="boolean"/>
    <attr name="fetch_user_info" format="boolean"/>
    <attr name="login_text" format="string"/>
    <attr name="logout_text" format="string"/>
</declare-styleable>

The problem is that I cannot resolve the ID of the defined ‘declare-styleable’ attribute – 0x00 is always returned:

int id = context.getResources().getIdentifier( "com_facebook_login_view", "declare-styleable", context.getPackageName() ); 
int[] resourceIDs = context.getResources().getIntArray( id );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:13:13+00:00Added an answer on June 15, 2026 at 6:13 pm

    Here is the solution that delivers the resource-IDs programmatically for the child-<attr>-tags defined for a <declare-styleable> tag:

    /*********************************************************************************
    *   Returns the resource-IDs for all attributes specified in the
    *   given <declare-styleable>-resource tag as an int array.
    *
    *   @param  context     The current application context.
    *   @param  name        The name of the <declare-styleable>-resource-tag to pick.
    *   @return             All resource-IDs of the child-attributes for the given
    *                       <declare-styleable>-resource or <code>null</code> if
    *                       this tag could not be found or an error occured.
    *********************************************************************************/
    public static final int[] getResourceDeclareStyleableIntArray( Context context, String name )
    {
        try
        {
            //use reflection to access the resource class
            Field[] fields2 = Class.forName( context.getPackageName() + ".R$styleable" ).getFields();
    
            //browse all fields
            for ( Field f : fields2 )
            {
                //pick matching field
                if ( f.getName().equals( name ) )
                {
                    //return as int array
                    int[] ret = (int[])f.get( null );
                    return ret;
                }
            }
        }
        catch ( Throwable t )
        {
        }
    
        return null;
    }
    

    Maybe this could help somebody one day.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a IDictionary<int, int> , is it possible to receive a IEnumerable<int>
Is it possible to receive objects of different Active Resource models in a single
I know its possible to receive a dayClick event on Fullcalendar. But I would
First, the simple question. Is it possible to receive an event when MEF (System.ComponentModel.Composition)
Is it possible for a receive statement to have multiple timeout clauses, and if
I was wondering is it possible to register a broadcast receiver to receive two
C# It's possible to set to a variant this sentence {D , and receive
Is it possible to constraint a method so that it receives only int ,
In MPI, is it possible to immediately throw out received data without allocating a
Is it possible to receive event/notification in my app when user uninstall my application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.