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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:16:06+00:00 2026-05-28T08:16:06+00:00

In the android tutorials, The GridView tutorial to be exact, there is a line

  • 0

In the android tutorials, The GridView tutorial to be exact, there is a line of code

GridView gridview = (GridView) findViewById(R.id.gridview);

Which looks to be declaring/instantiating a GridView object named, gridview and assigning from …
(GridView)

Now is the (GridView) in parens, the expected return type of findViewById or is it telling where to find findViewById since that doesn’t appear to be connected to an object (although, it would appear to be a member function of a GridView object)??

I believe that the findViewById returns an object of type GridView specified by the resource id of gridview (that we specied in main.xml) and probably now exists after we, earlier, called setContentView(R.layout.main);

So, what is being specified with the (GridView) part of the syntax and what is specifically meant by the parenthesis?

  • 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-28T08:16:07+00:00Added an answer on May 28, 2026 at 8:16 am

    findViewById returns a View, which is an abstract base class for all of Android’s UI. GridView inherits from other views that eventually inherit from View. So findViewById will take the ID you pass it and return the associated view as a View. The (GridView) casts the View to a GridView, allowing you to use the additional functionality of the GridView class.

    You would receive a ClassCastException if you tried to cast the result to something other than a GridView or one of GridView‘s super classes.

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

Sidebar

Related Questions

I've followed the tutorial here: http://developer.android.com/resources/tutorials/views/hello-gridview.html I'm wondering how I get place text over
The tutoriel in question is http://developer.android.com/resources/tutorials/views/hello-gridview.html The Tutorial asks that you 1- Create a
I am trying to implement the GridView tutorial at: http://developer.android.com/resources/tutorials/views/hello-gridview.html However, I get the
In the ImageAdapter class of this tutorial, http://developer.android.com/resources/tutorials/views/hello-gridview.html I would like to create and
I am following this tutorial https://developer.android.com/guide/tutorials/views/hello-tabwidget.html and have completed it. Now I would actually
if yes, is there a tutorial available for creating an android app using the
I am trying to modify this example: http://developer.android.com/resources/tutorials/views/hello-gridview.html But instead of displaying images that
I am following the Android Gallery tutorial ( http://developer.android.com/guide/tutorials/views/hello-gallery.html ) but instead of simple
i had followed exactly same procedure on google's tutorial: http://developer.android.com/guide/tutorials/views/hello-mapview.html ...while i got force
I've implemented the Hello Gallery tutorial from the Android web: http://developer.android.com/resources/tutorials/views/hello-gallery.html The tutorial shows

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.