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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:27:00+00:00 2026-06-05T05:27:00+00:00

I want to extend ListView but I do not understand what am I doing

  • 0

I want to extend ListView but I do not understand what am I doing wrong. Here is my code, very simple and basic:

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.test"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".TrymylistviewActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

res/layout/main.xml

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


<MyListView android:id="@+id/android:list"
      android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

<TextView android:id="@+id/android:empty"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"/>


</LinearLayout>

TrymylistviewActivity.java

package com.my.test;

import android.app.ListActivity;
import android.os.Bundle;

public class TrymylistviewActivity extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}
}

MyListView.java

package com.my.test;

    import android.content.Context;
    import android.util.AttributeSet;
    import android.widget.ListView;

    public class MyListView extends ListView {

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

public MyListView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public MyListView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

    }

If I use ListView instead of myListView in res/layout/main.xml the app runs in the emulator. But of course if I extend ListView with MListview then I want to use it. What am I doing wrong?

this is the beginning and the interesting part of the stack-trace.

06-08 22:51:33.409: E/AndroidRuntime(1141): FATAL EXCEPTION: main
06-08 22:51:33.409: E/AndroidRuntime(1141): java.lang.RuntimeException: Unable to start       activity ComponentInfo{com.my.test/com.my.test.TrymylistviewActivity}:   android.view.InflateException: Binary XML file line #8: Error inflating class MyListView
06-08 22:51:33.409: E/AndroidRuntime(1141):     at   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)... 11 more
....
06-08 22:51:33.409: E/AndroidRuntime(1141): Caused by: java.lang.ClassNotFoundException:   android.view.MyListView
06-08 22:51:33.409: E/AndroidRuntime(1141):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-08 22:51:33.409: E/AndroidRuntime(1141):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
....
06-08 22:51:33.409: E/AndroidRuntime(1141):     ... 21 more
  • 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-05T05:27:01+00:00Added an answer on June 5, 2026 at 5:27 am

    You have to use your own namespace:

        <MyListView android:id="@+id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
    

    should be:

        <com.my.test.MyListView android:id="@+id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do a very simple thing. I have a listview in my
I want to select all check boxes in a listview but I'm not able
I want to extend the IEnumerable class but only for types that can be
I realized,there're some questions here, but i think my code is really different from
I create a custom listview and it extend ListActivity and works fine. But I
I'm reading different forums for hours but I want to understand what is getting
I've tried to filter my ListView from my EditText box, but currently, it's not
I want to create listview. I got the value from the JSON. Here I
I want to extend a particular aspect of jQuery UI: https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.js Search in the
I want to extend NSSlider class to have an output textfield appended to it.

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.