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

  • Home
  • SEARCH
  • 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 6383025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:35:53+00:00 2026-05-25T02:35:53+00:00

I was trying to make an app with a custom view, and i kept

  • 0

I was trying to make an app with a custom view, and i kept getting “error inflating class”.
It must be that I am missing some of the basics when it comes to custom views, but I am not sure what. Here is a very simple program with a custom view, what more is needed to make it work?

(Notes: For the sake of this question, I put SurfaceView class inside of the Activity Class. This was not the situation in the larger application. I do not show the AndroidManifest.xml file here, but it is just what was generated by the wizard in eclipse.)

Here is the java:

package com.mypackage;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceView;

public class SimpleCustomViewActivity extends Activity {

class TheView extends SurfaceView{

    private static final String TAG = "TheView";

    public TheView(Context context, AttributeSet attrs) {
        super(context, attrs);
        Log.i(TAG,"TheView(" + context + "," + attrs + ")");
    }

}

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_layout);
        TheView v = (TheView) findViewById(R.id.myview);
    }
}

Here is file res/layout/simple_layout.xml:

<?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.mypackage.SimpleCustomView.TheView
    android:id="@+id/myview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
        />
</LinearLayout>
  • 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-25T02:35:53+00:00Added an answer on May 25, 2026 at 2:35 am

    in xml it should be:

     <com.mypackage.SimpleCustomView.TheView     
        android:id="@+id/myview"     
        android:layout_width="fill_parent"     
        android:layout_height="fill_parent"> 
     </com.mypackage.SimpleCustomView.TheView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a console app that would monitor some process and restart
i'm trying to make a custom Gallery in my app. I created a class
I am trying to make an app that will pass data between two servers
I am trying to make a web app in Dashcode that uses a range
I'm trying to make a simple app that sits on the Mac OSX menu
I'm trying to make an app for create custom cards. I'd like to add
I'm trying to make a quick sample Backbone.js app that has a Post model,
I got an article app and trying to make a custom filter, I have
Hello I am trying to make a terminal type app that is wider than
I'm trying to make a custom listview that will hold views of custom objects,

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.