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 6323769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:34:55+00:00 2026-05-24T16:34:55+00:00

Is it possible to get android to give me a custom id? so for

  • 0

Is it possible to get android to give me a custom id?

so for example if I already have defined in xml:

R.id.some_layout
R.drawable.some_drawable

is there any function like this

R.custom_id("a_custom_id")

so I could then access as

R.id.a_custom_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-05-24T16:34:57+00:00Added an answer on May 24, 2026 at 4:34 pm

    You can not dynamically create new IDs. Even if R was capable of doing so, you wouldn’t be able to access it using R.id.a_custom_id. Java is not dynamic language, and cannot add fields at runtime.


    There is, however, compile-time solution. In your res/values/ids.xml add:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
       <item type="id" name="a_custom_id"/>
    </resources>
    

    And then you can reference R.id.a_custom_id in your code and "@id/a_custom_id" in xmls. Of course its still pre-defined id (as opposed to runtime-defined id).

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

Sidebar

Related Questions

Is it possible to get the remaining battery time available from an Android phone?
Is it possible to get path of database file in android at path :
I´m having a problem with my Android Project. I have a screen filling custom
Possible Duplicate: How to get Latitude and Longitude of the mobiledevice in android? I
i want to get the SIM number programmatically.Is it possible in flex?In android developer
Is it possible to get any information about the package or the application from
I have an application in Android which get latitude and longitude from GPS. I
I currently have an activity with some buttons. In my xml, buttons are defined
I was wondering if its possible to get Android application info like (name, version,
I am wondering if its possible to get my android application to save a

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.