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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:01:01+00:00 2026-06-02T06:01:01+00:00

I know how to assing ID’s dynamically by invoking setID() . For the ID’s

  • 0

I know how to assing ID’s dynamically by invoking setID(). For the ID’s to be unique, I used to utilize ids.xml and pass to setID() ID’s from the pre-generated pool of ID’s.

Question 1: Is there any way to assign ID’s without utilizing the ids.xml since I cannot anticipate how many ID’s I will need in runtime?

I tried to bypass the first issue presented in Question 1 by dynamically assigning each of which an id based on its label’s hash (each label is unique), but there is no way to gaurantee that ID’s won’t be colliding with ID’s auto generated in R.java.

Question 1.1: How the ID naming collision can be resolved?

Question 2: Assume I have the ID value of which I assign and generate dynamically. Since the aformentioned ID does not appear in R.id, findViewById() won’t be applicable for retrieving the view. Hence, how can the view be retrieved when the ID is known?

Answer 2: You’d be able to retrieve the view by its corresponding ID only after onCreate() has returned control (terminated).

  • 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-02T06:01:03+00:00Added an answer on June 2, 2026 at 6:01 am

    Is there any way to assign ID’s without utilizing the ids.xml since I
    cannot anticipate how many ID’s I will need in runtime?

    This guarantees that every view has a unique ID

    for(int i =0 ; i < yourIDcount ; i++){
    yourView.setId(i);
    }
    

    how can the view be retrieved when the ID is known?

    View.findViewById(yourView.getId());
    

    can be used to get your view’s id, since every view has a unique Id you can get back the view you wanted..

    The word dynamic means which is created at runtime, since you assign id in onCreate it is assigned as the views id, since onCreate is called only once an activity is created, you can make sure that the id you assigned stays intact…

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

Sidebar

Related Questions

I have this html form to pass my data from iphone to web server..
I know what I asking might not make a lot of sense for C#
I want to know How JQuery assign function name to $ ?
I know there have been a million questions asking this, but mine is different.
I know the question I'm asking must be answered somewhere but I cant find
I'd like to know how I can assign in XAML a dependency property of
i dont know if i should be asking this here (im now thinking maybe
I know, I am asking stupid question but your experience will help me to
I know, I am asking very simple and stupid question but i want to
Does anyone know how can I cut a string and then assign into an

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.