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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:29:02+00:00 2026-05-18T20:29:02+00:00

I have a custom view (which extends GLSurfaceView) I’m trying to use in my

  • 0

I have a custom view (which extends GLSurfaceView) I’m trying to use in my app. The xml layout that uses it appears to be being loaded correctly (attributes I set for the view are applied), but neither the view’s constructor nor the onFinishInflate method are being called for the class. I should also add that I’m new to the android platform so this is probably a stupid mistake.

Here is my main.xml

<?xml version="1.0" encoding="utf-8"?>

#<!-- Status Bar -->
<LinearLayout 
    android:orientation="horizontal"
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"
    android:layout_weight="0"
    android:background="@drawable/status_bkg">

    #<!-- Location label -->
    <TextView 
        android:text="Location" 
        android:textColor="#FFFFFF"
        android:layout_weight="1" 
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    #<!-- Date/Time label -->
    <TextView 
        android:text="Date and Time" 
        android:textColor="#FFFFFF"
        android:layout_weight="1" 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="right"  />
</LinearLayout>

#<!-- ChartView -->
<View class="com.xxx.yyy.ChartView" android:id="@+id/chartView"
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:background="#00FF00" 
    android:layout_weight="1">
</View>

The ChartView is the custom GLSurfaceView. This layout is loaded and the ChartView has a green background as specified. However, none of my setup (in code) happens for it. I’ve tried placing it in the two constructors and in the onFinishInflate methods, but they inexplicably don’t get called. I’ve verified that the class name is correct (the xxx.yyy are just to hide the company in this post.

I’ve also tried a different form of the xml reference

    <com.xxx.yyy.ChartView android:id="@+id/chartView"
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:background="#00FF00" 
    android:layout_weight="1"/>

But this dies when loading the Activity says that the constructor

ChartView(Context context, AttributeSet attrs)

doesn’t exist (although it is certainly in my code).

Anyone got any tips on what could be going on?

  • 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-18T20:29:03+00:00Added an answer on May 18, 2026 at 8:29 pm

    I finally figured this out. I had defined my constructor (the one not getting called) as:

    public ChartView( MyActivity context, AttributeSet attrs )
    {
        super( context, attrs );
    ….        
    }
    

    However, it started working when I changed the constructor to be:

    public ChartView( Context context, AttributeSet attrs )
    {
        super( context, attrs );
    ….        
    }
    

    Given that MyActivity extends Activity (which extends Context), this is perfectly valid code and I believe it should work (it certainly compiles). It would seem there is an error in the reflection the system is using in locating this method.

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

Sidebar

Related Questions

I have a custom view (which extends GLSurfaceView) I'm trying to use in my
I have a custom view in my Android App that uses a ScaleGestureDetector.SimpleOnScaleGestureListener to
I have an activity with a custom view which extends EditText in it. Usually
I have a custom view which extends View. I am adding this to an
I have a custom view, the DateView (which extends a LinearLayout ) which when
I have a custom DownloadFiles class which extends AsyncTask . The app launches itself
I have a custom view which I call Node that is a child of
I have an activity which extends view i.e. its a custom view.I want to
I need to have a class which extends view that overrides the onSizeChanged method
I have a linear layout which holds inner (child) custom image view. My goal

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.