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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:30:14+00:00 2026-06-12T01:30:14+00:00

this is my first time using the ListView and have have tried out many

  • 0

this is my first time using the ListView and have have tried out many ways to make this workable. Firstly I used within the xml file under the to specify the “android:entries” with a string-array, it displayed but I could not activate the onClickListener. The other method were similar to the one that I have, some were where I used “extend Acitvity” instead. Thanks in advance for helping me.

Basically, I want to use a customized textView row for each item on the list and show a toast for each clickable row. My problem is that the application would crash the moment I try to display this activity. I am not sure where the problem is as there isn’t any syntax error. The error messages is ( Sorry, I would place a picture but I can’t – new user ) :

  • FATAL EXCEPTION: main
  • java.lang.RuntimeException:Unable to start activity ComponentInfo(edu…..)
  • at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202)
  • at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237)
  • at android.app.ActivityThread.access$600(ActivityTHread.java:139)
  • at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
  • at android.os.Handler.dispatchMessage(Handler.java:99)
  • at android.os.Looper.loop(Loooper.java:154)
  • at android.app.ActivityThread.main(ActivityThread.java:4974)
  • at java.lang.reflect.Method.invokeNative(Native Method)
  • at java.lang.reflect.Method.invoke(Method java:511)
  • at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  • at com.android.internal.os.ZygoteInit.main(ZygotaInit.java:551)
  • at dalvik.system.NativeStart.main(Native Method)
  • Caused by:java.lang.UnsupportedOperationException: addView(View, LayoutParams)…
  • at android.widget.AdapterView.addView(AdapterView.java:471)
  • at android.view.LayoutInflater.rInflate(LayoutInflater.java:743)
  • at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
  • at android.view.LayoutInflater.rInflate(LayoutInflater.java:489)
  • at android.view.LayoutInflater.rInflate(LayoutInflater.java:396)
  • at android.view.LayoutInflater.rInflate(LayoutInflater.java:352)
  • at com.android.internal.policy.impl.PhoneWindows.setContentView(PhoneWindow.java …)
  • at android.app.Activity.setContentView(Activity.java:1892)
  • at edu.nyp.wonderful.Menu.onCreate(Menu.java:14)
  • at android.app.Activity.performCreate(Activity.java:4538)
  • at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
  • at android.app.ActivityThread.performLaunchActivity(ActivityTHread.java:2158)
  • … 11 more lines ( I cannot show more to type out )

Menu.java v

package edu.nyp.wonderful;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;


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

        Log.d("Menu:", "after set content view");

        String[] items = { "Set Pins", "View Pins", "List of Pins", "Email Summary", "Edit Session's Info" };

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.menu_row, R.id.menu_name, items);
        setListAdapter(adapter);
        Log.d("Menu:", "after setting adapter");
    }

    protected void onListItemClick(ListView l, View v, int position, long id){
        super.onListItemClick(l, v, position, id);
        Toast.makeText(getApplicationContext(), "Clicked position: " + position, Toast.LENGTH_SHORT).show();
    }
}

menu.xml v

<?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"
    android:background="@drawable/background" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginBottom="10dp" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="54dp"
            android:layout_height="60dp"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="10dp"
            android:src="@drawable/logo" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Menu"
            android:textColor="#DC1700"
            android:textStyle="bold"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="30dp"
            android:textSize="25sp"
            android:typeface="serif" />
    </LinearLayout>

    <View android:id="@+id/separator1" 
         android:background="#000000" 
         android:layout_width = "fill_parent"
         android:layout_height="1dp"
         android:layout_marginBottom="10dp" />


    <ListView
        android:id="@+id/android:list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:divider="#000000"
        android:dividerHeight="1dp" >

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

    </ListView>
</LinearLayout>

*menu_row.xml v*

<?xml version="1.0" encoding="utf-8"?>
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/menu_name"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:textSize="23dp"
    android:shadowRadius="5"
    android:shadowColor="#000000"
    android:shadowDy="3"
    android:shadowDx="3"
    android:layout_marginLeft="10dp"
    android:layout_marginBottom="10dp"
    android:layout_marginTop="10dp" />
  • 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-12T01:30:15+00:00Added an answer on June 12, 2026 at 1:30 am

    Yeah, this is the problem.

    android:id="@+id/android:list"
    

    It should be

    android:id="@android:id/list"
    

    Fix it and check, report back if the problem persists.

    Update: I can’t believe I didn’t see it earlier 😛

    You have a TextView inside the Listview. This is not possible. If you intend to use the “Empty View” Have them both inside a LinearLayout/FrameLayout. But the Listview cannot enclose the TextView, they should lie next to each other. Then, make sure you set the “Empty View” property in the “ListView” to the id of the Textview in this case @android:id/empty (please correct this as well)

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

Sidebar

Related Questions

This is my first time using XML documents. What I'm trying to do is
This is my first time using this site and I am quite new to
This is my first time using lightbox which uses jquery framework. But when I
This is my first time using an external library, and I'm a bit nervous
This is my first time using jQuery and I am pleased to get my
This is my first time using Google Analytics Ecommerce Tracking to get data for
this is my first time using StAX for parsing XML documents (still in the
So this is my first time using cookies and i'm having some trouble setting
Sorry, this is my first time using this forum. Apparently people can edit my
I'm fairly new to both Django and Python. This is my first time using

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.