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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:37:31+00:00 2026-06-05T03:37:31+00:00

This is the description given for the setId() method. void android.view.View.setId(int id) public void

  • 0

This is the description given for the setId() method.

void  android.view.View.setId(int id)

public void setId (int id)

Since: API Level 1

Sets the identifier for this view. The identifier does not have to be
unique in this view’s hierarchy. The identifier should be a positive
number.

My question is, why does the identifier not have to be unique in this view’s hierarchy though we assign unique ids in an XML file?

  • 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-05T03:37:35+00:00Added an answer on June 5, 2026 at 3:37 am

    My question is, why does the identifier not have to be unique in this view’s hierarchy though we assign unigue id in xml file..?

    The android:id does not have to be unique in the XML file, either, though that is the way you write it, typically.

    To understand why a widget ID does not need to be unique, consider the ListView. Let’s say that we have a ListView with 8 rows. Each of those rows is created by inflating a layout XML resource (e.g., android.R.layout.simple_list_item_1). Each of those inflated rows are children of the ListView. Yet, since each of those rows is inflated from the same layout resource, each row’s widgets have the same IDs as all the other rows.

    This is not generally a problem. It does lead to one cardinal rule of Android development: always call findViewById() on something that will give you a unique result for the widget you seek. In this case, I do not want to call findViewById() on the ListView or the Activity to find a widget inside of one of the rows, as there will be 8 widgets all with the same ID, and I do not know which row’s widget I will get back. Instead, I need to call findViewById() on the row, to get the particular widget from that specific row.

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

Sidebar

Related Questions

I have something like this: [Description(Sets the color.), Category(Values), DefaultValue(Color.White), Browsable(true)] public Color MyColor
In the api doc for play.db.jpa.Model ,the description for the method refresh() is given
I've just read this description of the Android Support Package / Compatibility Library... http://developer.android.com/sdk/compatibility-library.html
I have an enum with Description attributes like this: public enum MyEnum { Name1
Given the following text: |Description=This is the start of the ... ... <strong>description</strong> of
In tastypie my url: /api/v1/course/1/?format=json gives the following json: { created_on: 2012-02-27T08:00:54, description: this
This is a description of how to create a helper method in Rspec taken
Here's the description of this problem: You are given two integers a and b.
Given a JSON string like this: {Locations: {list: [ {description: some description, name: the
Given the two sample tables here: Tickets Table ID User Description 0 James This

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.