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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:08:57+00:00 2026-05-21T16:08:57+00:00

I have a program, it works. I’m trying to get one of the SurfaceViews

  • 0

I have a program, it works. I’m trying to get one of the SurfaceViews that was declared in an XML resource to be accessible in an Activity class. The surfaceview is assigned alright and allows access the SurfaceView methods/elements, but not my custom ones. How do I access the custom elements?

public class main extends Activity {
  SurfaceView viewer;

  public void onCreate(...) {
    ...
    //Successfully assigns object to viewer
    viewer = (SurfaceView)findViewById(R.id.Viewer); 
  }

  void someMethod(){
    viewer.doSomethingRad(); //FAIL
  }
}
//////////////
public class Viewer extends SurfaceView... {
  ....
}
/////////////Main.xml
...
~view class="com.ballroll.Viewer" 
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" 
  android:id="@+id/Viewer" 
  android:text="Viewer"~
~/view~
//I don't know how to escape '

WTF? Thanks in advance!

  • 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-21T16:08:58+00:00Added an answer on May 21, 2026 at 4:08 pm

    You are declaring the view as a SurfaceView. You should declare it using your class name.

     Viewer viewer;
    
      public void onCreate(...) {
        ...
        //Successfully assigns object to viewer
        viewer = (Viewer)findViewById(R.id.Viewer); 
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a program that uses qhttp to get a webpage. This works
I have an OpenGL program that works on all of my computers but one.
I have a program that works with a variety of files on both the
I have a program that works with multiple threads. For each I set uncaught
I have a popup function in a program that works well, be re-loads the
I have a C program that I know works on 32-bit systems. On 64-Bit
I have a client program that consumes a web service. It works quite well
I have a program that works when, a file is opened with it using
I have a C# program that works correctly on xp and vista but it
This can be a handy functionality to have in a program that works with

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.