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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:00:46+00:00 2026-06-17T19:00:46+00:00

I am using Eclipse. My application selects a value from a list view in

  • 0

I am using Eclipse. My application selects a value from a list view in android and must display the value in another activity, but it is not happening.

As soon as I click on the list i get the error activity has stopped working

i get errors like this in all my applications

i made another application based on this tutorial

http://www.vogella.com/articles/AndroidSQLite/article.html

My code consists of two activities:

MainActivity.java

package event.scheduler;
import android.os.Bundle;    
import android.util.Log;    
import android.view.View;    
import android.app.ListActivity;    
import android.content.Intent;    
import android.widget.ArrayAdapter;    
//import android.widget.Toast;    
import android.widget.ListView;    
public class MainActivity extends ListActivity {
public final static String EXTRA_MESSAGE = "event.scheduler.MESSAGE";

@Override
    protected void onCreate(Bundle savedInstanceState) {
    try
    {
    super.onCreate(savedInstanceState);
    String[] values = new String[]{"Conatus","Horizon","Orja","Phoniex"};
    ArrayAdapter <String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,values);
    setListAdapter(adapter);
}
    catch(RuntimeException e){
        Log.i("sdv","dsvg");
        }
    }           

@Override   
protected void onListItemClick(ListView l, View v, int position, long id) {
     try
        {

    String item = (String)getListAdapter().getItem(position);
   Intent intent = new Intent(this,Display.class);
   intent.putExtra(EXTRA_MESSAGE,item);
   startActivity(intent);
   }

catch(RuntimeException e)
{
    Log.i("log","view");
}
}          // Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show(); 

}

Display.java

     package event.scheduler;

     import android.os.Bundle;
     import android.app.Activity;
     import android.app.ListActivity;
     import android.content.Intent;
     import android.util.Log;

     import android.widget.TextView;

     public class Display extends Activity {

TextView textview;
@Override
protected void onCreate(Bundle savedInstanceState) {
    //try
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_display);
    Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
    textview= (TextView)findViewById(R.id.your_texbox);
    textview.setTextSize(40);
    textview.setText(message);

    setContentView(textview);

    }
    //catch(RuntimeException e)
    {
    //  Log.i("sfs", "message");
        }
    }

}

my xml files are

activity_display.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Display" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="@string/hello_world" />

activity_main.xml

               <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<ListView
    android:id="@+id/mylist"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
</ListView>

my manifest file is

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="event.scheduler.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="event.scheduler.Display"
        android:label="@string/title_activity_display" >
    </activity>
</application>

my logcat is

01-20 14:49:01.171: D/AndroidRuntime(1278): Shutting down VM
01-20 14:49:01.181: W/dalvikvm(1278): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
01-20 14:49:01.301: E/AndroidRuntime(1278): FATAL EXCEPTION: main
01-20 14:49:01.301: E/AndroidRuntime(1278): java.lang.RuntimeException: Unable to start activity ComponentInfo{event.scheduler/event.scheduler.Display}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.os.Looper.loop(Looper.java:137)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.app.ActivityThread.main(ActivityThread.java:5039)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at java.lang.reflect.Method.invokeNative(Native Method)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at java.lang.reflect.Method.invoke(Method.java:511)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at dalvik.system.NativeStart.main(Native Method)
01-20 14:49:01.301: E/AndroidRuntime(1278): Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.view.ViewGroup.addViewInner(ViewGroup.java:3339)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.view.ViewGroup.addView(ViewGroup.java:3210)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.view.ViewGroup.addView(ViewGroup.java:3186)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:289)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:279)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.app.Activity.setContentView(Activity.java:1901)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at event.scheduler.Display.onCreate(Display.java:26)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.app.Activity.performCreate(Activity.java:5104)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-20 14:49:01.301: E/AndroidRuntime(1278):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-20 14:49:01.301: E/AndroidRuntime(1278):     ... 11 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-17T19:00:47+00:00Added an answer on June 17, 2026 at 7:00 pm

    as in log:

    Your content must have a ListView whose id attribute is
    ‘android.R.id.list’

    change ListView id to android:id="@android:id/list" if you are extending ListActivity

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
    </ListView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an android application using eclipse. I have a main activity called MenuActivity
I am developing an android mobile application using eclipse. I need a database that
i am building a server application using eclipse , and the client is android
I am currently developing an android application using eclipse and I already have a
I have developed the Hello World Android application using Eclipse. I can run the
I'm using Eclipse Ganymede to create a web application, but the project's currently just
I have developed an Android application using Eclipse which works perfectly on the Android
im actually dotnet developer now im starting to develop mobile application using eclipse android
I am developing an android application(using Eclipse 3.5.2, Android 2.2) where i need to
I'm developing an android application using eclipse (ADT). I've been doing it for a

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.