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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:10:45+00:00 2026-05-23T05:10:45+00:00

all throughout the developer documents & tutorials , they reccomend use of findViewById() to

  • 0

all throughout the developer documents & tutorials, they reccomend use of findViewById() to “Find a view that was identified by the id attribute from the XML that was processed in onCreate(Bundle)” so i exclusively had been using that everywhere i needed a view to reference something in an xml file. this had caused a number of problems, like if i needed to use a view within a static method, or, as far as i can tell, any method aside from onCreate. recently i stumbled upon setId() which, in addition to being briefer to write and being more readable since it is following the standard “getters & setters” protocol, also seems to have no requirements as to where you use it within your app.

what actually is the difference between:

setId – “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.”

&

findViewById – “Look for a child view with the given id. If this view has the given id, return this view.”

are they interchangeable? are there circumstances that only allow use of one or the other?

  • 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-23T05:10:45+00:00Added an answer on May 23, 2026 at 5:10 am

    These are completely different methods. In fact, setId is useful to set an ID of a view so that you can use findViewById later to find it again. You use findViewById when you know the ID of a view, and you want to get the actual View object associated with that ID. You use setId when you already have a View object, and you want to set an identifier for it, so that later on you can find that same View object again using findViewById.

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

Sidebar

Related Questions

I'm trying to add a function that will be accessible throughout all parts of
We have an ASP.NET webforms app that has try/catch blocks all throughout. In the
All throughout an application wherever error messages (or other user messages) are used I
We have hundreds of document libraries, spread all throughout various site collections in a
All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
I have an XML file that I want to sort by an attribute. The
So my problem is this. I have a class called Globals that contains all
I have an application that loads dlls dynamically. The application and the dlls use
when they say static classes should not have state/side effects does that mean: static
I've inherited an iPhone app that has a file containing all code necessary to

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.