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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:52:49+00:00 2026-06-15T19:52:49+00:00

Suppose if I am using a same id for two different views in two

  • 0

Suppose if I am using a same id for two different views in two different layouts, I can see only one refernce is created for the id in the class “id” in R.java. Actually what I think is that it should show an error when trying to add the constant with the same name in the class “id” on build .Why its not showing an error?.And how it identifies two different views with a single 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-15T19:52:51+00:00Added an answer on June 15, 2026 at 7:52 pm

    If you have two different people, in 2 different groups, both named Vicky, it does not matter who that person is when calling the name (=id). If you call ‘Vicky’ in the first group, the Vicky in THAT group responds.
    In android, you assign a ‘group’ of views to the activity by using setContentView(<layout file>) where <layout file> is the group.
    If you request a view by findViewWithId() with a id which is not available (as in, not in the loaded layout file), it returns null.

    example:

    layout1.xml contains

    <View id="@+id/name1"/>
    <View id="@+id/name2"/>
    <View id="@+id/name3"/>
    

    layout2.xml contains

    <View id="@+id/name1"/>
    <View id="@+id/name3"/>
    

    Calling findViewById(R.id.name1) on the first and second layout file, will return the first view. But when you call findViewById(R.id.name2) on the 2nd layout, it will return null. The id DOES exist in A layout file, but simply not in the ‘loaded’ layout file.

    Id’s are not references to View objects. They are identifiers that can be used by multiple Views in different layouts. By looking for an identifier in the layout file, you can acquire a reference to the View using it.

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

Sidebar

Related Questions

Suppose we have an object that can be sorted using two or more comparison
Suppose I'm using transactional replication to replicate articles from one server to another (
Suppose one person is using Bazaar 2.3 on Linux, and another is using Bazaar
Suppose I created index with descending order CREATE INDEX `MyTable.MyIndex` USING BTREE ON `MyTable`
Suppose I let the user to write a condition using Javascript, the user can
How do you put two different function outputs from the same controller into the
I have a tricky problem related to synchronized scrolling of two different views. I've
I have two different database in different machine.Both the have same tables and i
Suppose I have two url for the same file, say http://site.com/fr/page.php and http://site.com/en/page.php .
Suppose I am using an ApplicationContext implementation in Spring. ApplicationContext is an interface in

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.