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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:30:24+00:00 2026-06-08T02:30:24+00:00

here is my xml in which i am using my custom view . that

  • 0

here is my xml in which i am using my custom view . that view is in another package named com.soft.MyView and the class which is extending view is also named MyView now m getting force close and the error in logcat is 07-21 16:26:29.936: ERROR/AndroidRuntime(19854): Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class com.soft.MyView.MyView ..plss tell me where am i wrong??

       <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout1" xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView android:id="@+id/TextView1" android:layout_alignParentLeft="true" android:layout_alignParentTop="true"  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
<com.soft.MyView.MyView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/TextView1" android:layout_centerHorizontal="true" android:layout_marginTop="187dp" android:id="@+id/drawingImageView"/>
</RelativeLayout>

and here is my class MyView

    public class MyView extends View{



class Pt{

    float x, y;



    Pt(float _x, float _y){

        x = _x;

        y = _y;

    }

}



Pt[] myPath = { new Pt(100, 100),

                new Pt(200, 200),

                new Pt(200, 500),

                new Pt(400, 500),

                new Pt(400, 200)

                };



    public MyView(Context context) {

        super(context);

        // TODO Auto-generated constructor stub

    }



    @Override

    protected void onDraw(Canvas canvas) {

        // TODO Auto-generated method stub

        super.onDraw(canvas);





        Paint paint = new Paint();

        paint.setColor(Color.WHITE);

        paint.setStrokeWidth(3);

        paint.setStyle(Paint.Style.STROKE);

        Path path = new Path();



        path.moveTo(myPath[0].x, myPath[0].y);

        for (int i = 1; i < myPath.length; i++){

            path.lineTo(myPath[i].x, myPath[i].y);

        }

        canvas.drawPath(path, paint);



    }



}
  • 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-08T02:30:26+00:00Added an answer on June 8, 2026 at 2:30 am
    • the reason for your problem is that you used only the code-version CTOR:

      public View (Context context)

      quote from android developers guide:

      Simple constructor to use when creating a view from code.

    • the solution would be to add all of the possible CTORs that the custom view needs for the layout inflating process, or at least this one:

      public View (Context context, AttributeSet attrs)

      quote from android developers guide:

      Constructor that is called when inflating a view from XML. This is
      called when a view is being constructed from an XML file, supplying
      attributes that were specified in the XML file. This version uses a
      default style of 0, so the only attribute values applied are those in
      the Context’s Theme and the given AttributeSet.

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

Sidebar

Related Questions

I have a client that sends an xml feed which I parse using the
I found here that Magento is using these tags as custom config variables, but
I'm using the custom progress dialog given here , which as the style shown
I have created a custom listview that is populated using a row.xml file. Each
in my project I have a Panel which is using a custom skin that
I have <.ImageView> enter code here s(icons) in my android layout xml file, which
here is the XML file : <com.google.android.maps.MapView android:layout_width=fill_parent android:layout_height=fill_parent android:apiKey=0q7NUYm4bgzeXlqXtKYVPJDRWUJmt8Cu0gvbWMx android:id=@+id/map_view /> and Manifest
My application consists of a MapActivity , which loads an XML view (map_layout), containing
G'day guys, I've tried reading the XML Modularization recommendation which promises to allow custom
I'm building a Flex application using some custom components, which I think is messing

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.