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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:56:35+00:00 2026-05-27T01:56:35+00:00

Is it possible to have a class extending SurfaceView within the activity class as

  • 0

Is it possible to have a class extending SurfaceView within the activity class as an inner class? Something like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.android.iiProject.Presentation.DrawCanvas
android:id="@+id/SurfaceView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>

Where the Presentation is the activity class, and the DrawCanvas is the class extending the SurfaceView, and a DrawCanvas object is called from within the Presentation activity.

I want it this way because I want to have access to methods and variables available from within the Presentation activity, and I don’t want to declare them as static to reach them from the other class, since that causes me a lot of additional problems…!
This way it’s giving me classNotFoundException at the XML file

Thanks a lot 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-27T01:56:36+00:00Added an answer on May 27, 2026 at 1:56 am

    Yes, that’s possible, you just have to adress you inner class in a different way from XML, like this:

    <view
      class="com.yourpackage.YourOuterClass$YourInnerClass" 
      ...
      />
    

    Quote:

    The custom component is created as a generic view in the XML, and the
    class is specified using the full package. Note also that the inner
    class we defined is referenced using the NoteEditor$MyEditText
    notation which is a standard way to refer to inner classes in the Java
    programming language.
    If your custom View component is not defined as
    an inner class, then you can, alternatively, declare the View
    component with the XML element name, and exclude the class attribute.

    See modifying an existing view type, point 4.

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

Sidebar

Related Questions

Is it possible to have something like the following: class C { public Foo
Anyone knows if is possible to have partial class definition on C++ ? Something
This is probably not possible, but I have this class: public class Metadata<DataType> where
I'd like to create my own class extending array of ints. Is that possible?
I have a class like this: class SomeClass { public: QString data; SomeClass(const QString
In C++, is it possible to have a child class hide a base class'
it's possible to have one entity object (class, e.g. User) for more entity models
I have a class with many collections loaded in memory. Is it possible to
Is it possible in Delphi to have a class method invoke an inherited instance
Is it possible to have multiple classes that inherit/extends same class in Google AppEngine

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.