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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:58:36+00:00 2026-06-14T12:58:36+00:00

I write a simple extend view class,the code is following: public class MyView extends

  • 0

I write a simple extend view class,the code is following:

public class MyView extends View
 {

   public MyView(Context context)
    {
        super(context);
    }

     public MyView(Context context, AttributeSet attrs) {
         super(context, attrs);
         // TODO Auto-generated constructor stub
     }

    protected void OnDraw(Canvas canvas)
     {
         super.onDraw(canvas);
     }
 }

XML:
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent" >


       <com.main.sufaceview.MyView
            android:id="@+id/myview"
            android:layout_width="300dp"
            android:layout_height="300dp"
            android:background="@drawable/tt"/>  

</RelativeLayout>

When entry the virtual machine. It shows the breakdown:
enter image description here

why this is? i think the custom view should very easy.I did not add other code,it has the error.
Edit:the logcat displays:
enter image description here

  • 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-06-14T12:58:37+00:00Added an answer on June 14, 2026 at 12:58 pm

    I think you need another constructor, at least, thats what I read in other posts.

    public MyView(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i write the simple android code for one activity and provided its view by
Hi I have write this code to move a simple ball with an ImageView
I write a simple game with the following structure. Main xml layout have user
In trying to write more testable Java code, I have been using the Model-View-Presenter
I'm trying to write a simple timer app. I'm creating a counter class that
public class ListView extends ListActivity { static String item; public void onCreate(Bundle icicle) {
Lets write simple console application (debug mode): static void Main(string[] args) { Process p
Lets write simple console application: static void Main(string[] args) { IList<Thread> threads = new
I'm trying to write simple proxy server for some purpose. In it I use
I want to write simple script to copy/backup directory then remove on server startup.

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.