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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:16:32+00:00 2026-05-25T11:16:32+00:00

Possible Duplicate: Android ListView, start new activity Hey can someone tell me how I

  • 0

Possible Duplicate:
Android ListView, start new activity

Hey can someone tell me how I can start an activity by pressing an item in a listview?

I have fixed it i think because i get no error messages, but when i start this activity (Videos) the app crashes and wants to force close. Whats the problem?

Here is the source code:

package com.alpha.liveshit;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Videos extends ListActivity {

    String[] elements = {"video", "menu"};

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.videos); 
        ListView listview = (ListView)findViewById(R.id.listView1);
        listview.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, elements));
    }

    public void onListItemClick(ListView parent, View v, int position, long id) {

        if ("video".equals(elements[position])) { 
            Intent myIntent = new Intent(Videos.this, Lars.class);
            startActivity(myIntent);
        }
        else if ("menu".equals(elements[position])) {
            Intent myIntent = new Intent(Videos.this, MenuActivity.class);
            startActivity(myIntent);
        }
    }
}

LOGCAT

09-07 20:34:21.559: ERROR/AndroidRuntime(326): FATAL EXCEPTION: main
09-07 20:34:21.559: ERROR/AndroidRuntime(326): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alpha.liveshit/com.alpha.liveshit.Videos}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.os.Looper.loop(Looper.java:123)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at java.lang.reflect.Method.invokeNative(Native Method)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at java.lang.reflect.Method.invoke(Method.java:521)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at dalvik.system.NativeStart.main(Native Method)
09-07 20:34:21.559: ERROR/AndroidRuntime(326): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.app.ListActivity.onContentChanged(ListActivity.java:245)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.app.Activity.setContentView(Activity.java:1647)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at com.alpha.liveshit.Videos.onCreate(Videos.java:17)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-07 20:34:21.559: ERROR/AndroidRuntime(326):     ... 11 more
09-07 20:34:21.569: WARN/ActivityManager(60):   Force finishing activity com.alpha.liveshit/.Videos
09-07 20:34:21.580: WARN/ActivityManager(60):   Force finishing activity com.alpha.liveshit/.MenuActivity
09-07 20:34:22.079: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{450915a0 com.alpha.liveshit/.Videos}
09-07 20:34:32.477: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{45140c78 com.alpha.liveshit/.MenuActivity}
09-07 20:34:32.479: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{450915a0 com.alpha.liveshit/.Videos}
09-07 20:34:35.058: INFO/Process(326): Sending signal. PID: 326 SIG: 9
09-07 20:34:35.229: INFO/ActivityManager(60): Process com.alpha.liveshit (pid 326) has died.
09-07 20:34:35.229: INFO/WindowManager(60): WIN DEATH: Window{4508ddb0 com.alpha.liveshit/com.alpha.liveshit.MenuActivity paused=true}
09-07 20:35:45.255: DEBUG/SntpClient(60): request time failed: java.net.SocketException: Address family not supported by protocol
09-07 20:37:00.329: DEBUG/dalvikvm(60): GC_FOR_MALLOC freed 19005 objects / 859600 bytes in 249ms
  • 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-25T11:16:32+00:00Added an answer on May 25, 2026 at 11:16 am

    Remove that

    setContentView(R.layout.videos); 
    ListView listview = (ListView)findViewById(R.id.listView1);
    

    and replace it with that

    ListView listview = getListView();
    

    You’re using a ListActivity. You may not set a content view on a ListActivity(it already contains a ListView)

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

Sidebar

Related Questions

Possible Duplicate: What is Context in Android? Can anybody please tell me about the
Possible Duplicate: Android Activity Life Cycle - difference between onPause() and OnStop() Can anybody
Possible Duplicate: Listview inside ScrollView is not scrolling on Android I have a ListView
Possible Duplicate: Problem installing my Android apps Any body can tell me how can
Possible Duplicate: Android - shadow on text? How can i make shadow effect text
Possible Duplicate: Why is my android alarm manager firing instantly? I have this code
Possible Duplicate: twitter integration on android app How can I integrate Twitter with my
Possible Duplicate: Can we delete an SMS in Android before it reaches the inbox?
Possible Duplicate: How to test the performance of an Android application? How can i
Possible Duplicate: Android FTP Library I am very much new to the android development,

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.