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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:52:57+00:00 2026-05-27T00:52:57+00:00

I have just started working with Android ListView . However, setAdapter function in my

  • 0

I have just started working with Android ListView. However, setAdapter function in my program works only when ListActivity is extended by class DisplayMovie. While I use ListActivity and remove Activity, the application crashes. Since multiple Inheritance cannot be supported, I wish to know if there is a way by which I can use both ListViewActivity as well as Activity classes in my program.

//public class DisplayMovies extends ListActivity {
public class DisplayMovies extends Activity {
    /** Called when the activity is first created. */
    public String flixURL="";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main3);

        Bundle extras = getIntent().getExtras();        
        int myzip = extras.getInt("globalZip");        
        flixURL=("http://servermin.com:19818/cgi-bin/movielog.pl?zip=" + myzip);        
        displayAllMovieList();                
    }

    public void displayAllMovieList()
    {
        SAXBuilder builder = new SAXBuilder();
        URL url;

        try 
        {
            url = new URL(flixURL);
            Document doc = null;
            doc=builder.build(url);             
            Element root = doc.getRootElement();                                
            List children = root.getChild("movies").getChildren("movie");

            System.out.println("Tracker3");
                    int MovieNum=children.size();  //Count the number of Movies                 
                    String[] MovieName=new String[MovieNum]; //Initialize a String 
                    String[] MovieCover=new String[MovieNum];                                       
                    String[] ShowTime=new String[MovieNum];                 
                    String TheatereName = ((Element) doc.getRootElement().getChild("movies").getChildren("movie").get(0)).getAttributeValue( "theatre" );                                       
                    String TweetText="";                                          
                    for (int i = 0; i < children.size(); i++) 
                    {   
                        Element movieAtt = (Element)doc.getRootElement().getChild("movies").getChildren("movie").get(i);                                            
                        MovieName[i]=movieAtt.getAttributeValue( "Title" );
                        MovieCover[i]=movieAtt.getAttributeValue( "cover" );
                        ShowTime[i]=movieAtt.getAttributeValue( "showtime" );
                            finalTime=movieAtt.getAttributeValue( "showtime" ).substring(0,8);
                        TweetText+=" I will see "+movieAtt.getAttributeValue("Title")+" at "+TheatereName+" at "+finalTime+"\n";


                        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, MovieName);
                        setListAdapter(adapter);

                        //TextView tv = new TextView(this);
                        //tv.setText(TweetText);
                        //setContentView(tv);                                               
                    }                     

        } 
        catch (MalformedURLException e1) 
        {
            e1.printStackTrace();
            System.out.println("ErrorThrowedIs: "+e1);
            Toast.makeText(getBaseContext(), e1.toString(),5);
        } 
        catch (JDOMException e2) 
        {
            e2.printStackTrace();
            System.out.println("ErrorThrowedIs: "+e2);
            Toast.makeText(getBaseContext(), e2.toString(),5);
        }
        catch (IOException e3) 
        {
            e3.printStackTrace();
            System.out.println("ErrorThrowedIs: "+e3);
            Toast.makeText(getBaseContext(), e3.toString(),5);
        }
    }
}

Error Log Says :

11-21 02:18:19.609: W/dalvikvm(21193): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
11-21 02:18:19.629: E/AndroidRuntime(21193): FATAL EXCEPTION: main
11-21 02:18:19.629: E/AndroidRuntime(21193): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vj/com.vj.DisplayMovies}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.os.Looper.loop(Looper.java:123)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.app.ActivityThread.main(ActivityThread.java:4627)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at java.lang.reflect.Method.invokeNative(Native Method)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at java.lang.reflect.Method.invoke(Method.java:521)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at dalvik.system.NativeStart.main(Native Method)
11-21 02:18:19.629: E/AndroidRuntime(21193): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.app.ListActivity.onContentChanged(ListActivity.java:245)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:203)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.app.Activity.setContentView(Activity.java:1647)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at com.vj.DisplayMovies.onCreate(DisplayMovies.java:30)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-21 02:18:19.629: E/AndroidRuntime(21193):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-21 02:18:19.629: E/AndroidRuntime(21193):    ... 11 more

Updated XML:

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

<ListView android:id="@android:id/list"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:background="#00FF00"
               android:layout_weight="1"
               android:drawSelectorOnTop="false"/>

     <TextView android:id="@android:id/empty"
               android:layout_width="match_parent"
               android:layout_height="match_parent"
               android:background="#FF0000"
               android:text="No data"/>

 </LinearLayout>

Updated Code for the class:

public class DisplayMovies extends ListActivity {
//public class DisplayMovies extends Activity {
    /** Called when the activity is first created. */
    public String flixURL="";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main3);

        Bundle extras = getIntent().getExtras();        
        int myzip = extras.getInt("globalZip");        
        flixURL=("http://myweb.com/cgi-bin/movielog.pl?zip=" + myzip);      
        displayAllMovieList();                
    }

    public void displayAllMovieList()
    {
        SAXBuilder builder = new SAXBuilder();
        URL url;

        try 
        {
            url = new URL(flixURL);
            Document doc = null;
            doc=builder.build(url);             
            Element root = doc.getRootElement();                                
            List children = root.getChild("movies").getChildren("movie");

            System.out.println("Tracker2");
                    System.out.println("Tracker3");
                    int MovieNum=children.size();  //Count the number of Movies                 
                    String[] MovieName=new String[MovieNum]; //Initialize a String 
                    String[] MovieCover=new String[MovieNum];                                       
                    String[] ShowTime=new String[MovieNum];                 
                    String TheatereName = ((Element) doc.getRootElement().getChild("movies").getChildren("movie").get(0)).getAttributeValue( "theatre" );                                       
                    String TweetText="";                                          
                    for (int i = 0; i < children.size(); i++) 
                    {   
                        Element movieAtt = (Element)doc.getRootElement().getChild("movies").getChildren("movie").get(i);                                            
                        MovieName[i]=movieAtt.getAttributeValue( "Title" );
                        MovieCover[i]=movieAtt.getAttributeValue( "cover" );
                        ShowTime[i]=movieAtt.getAttributeValue( "showtime" );
                            finalTime=movieAtt.getAttributeValue( "showtime" ).substring(0,8);  TweetText+=" I will see "+movieAtt.getAttributeValue("Title")+" at "+TheatereName+" at "+finalTime+"\n";


                        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, MovieName);
                        setListAdapter(adapter);


                }               
        } 
        catch (MalformedURLException e1) 
        {
            e1.printStackTrace();
            System.out.println("ErrorThrowedIs: "+e1);
            Toast.makeText(getBaseContext(), e1.toString(),5);
        } 
        catch (JDOMException e2) 
        {
            e2.printStackTrace();
            System.out.println("ErrorThrowedIs: "+e2);
            Toast.makeText(getBaseContext(), e2.toString(),5);
        }
        catch (IOException e3) 
        {
            e3.printStackTrace();
            System.out.println("ErrorThrowedIs: "+e3);
            Toast.makeText(getBaseContext(), e3.toString(),5);
        }
    }
}
  • 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-27T00:52:58+00:00Added an answer on May 27, 2026 at 12:52 am

    First of all, if your app crashes, and you’re asking a question, make sure you also include the stacktrace from the log.

    Regarding your question, make sure you understand the preconditions to using ListActivity: you MUST have a listview in your layout, with an android:id="@android:id/list" (as stated in the docs). I’m quite positive this is the reason your app crashes.

    You don’t need multiple inheritance here anyway: ListActivity extends Activity, it would make no sense to extend them both, even if Java had multiple inheritance.

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

Sidebar

Related Questions

I have just started working on my first Android application and am going ok.
Just started working with android and ran into a small problem. I am have
I have started working on android just 1 month back (so please consider my
I have started working on a simple XML pull-parser, and as I've just defuzzed
I have just started my career as an android programmer, and am currently relying
I've started working on some Android applications and have a question regarding how people
I have just started working with nodejs. I wonder if there is a way
I have just started working on an open source project. The project is hosted
I am a beginner to iOS development and have just started working with the
Being a somewhat proficient iOS developer, I have just started working on a desktop

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.