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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:55:57+00:00 2026-06-17T11:55:57+00:00

I am getting a run time exception java.lang.RuntimeException: Your content must have a ListView

  • 0

I am getting a run time exception java.lang.RuntimeException: Your content must have a ListView whose id attribute is ‘android.R.id.list’. Not sure what is wrong here.I looked at some other answers and it seemed that changing the ListView id to list was the issue but that does not seem to be working.

activity_search.xml

        <ListView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1" >
        </ListView>

    </LinearLayout>

list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<!--  Single List Item Design -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/name"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="10dip"
        android:textSize="16dip"
        android:textStyle="bold" >
</TextView>

SearchActivity.java

package com.chance.squat;

import com.chance.squat.R;
import java.util.ArrayList;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class SearchActivity extends ListActivity {

    // url to make request
    private static String url = "http://192.168.1.115:3000/bathrooms/nearby.json/?lat=45.580639&lon=-122.677682";

    // JSON Node names
    private static final String TAG_BATHROOMS = "bathrooms";
    private static final String TAG_ID = "ID";
    private static final String TAG_NAME = "name";
    private static final String TAG_DISTANCE = "distance";

    // contacts JSONArray
    JSONArray bathrooms = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);     
        setContentView(R.layout.activity_search);

        // Hashmap for ListView
        ArrayList<HashMap<String, String>> bathroomList = new ArrayList<HashMap<String, String>>();

        // Creating JSON Parser instance
        JSONParser jParser = new JSONParser();

        // getting JSON string from URL
        JSONObject json = jParser.getJSONFromUrl(url);

        try {
            // Getting Array of Contacts
            bathrooms = json.getJSONArray(TAG_BATHROOMS);

            // looping through All Contacts
            for(int i = 0; i < bathrooms.length(); i++){
                JSONObject c = bathrooms.getJSONObject(i);

                // Storing each json item in variable
                String id = c.getString(TAG_ID);
                String name = c.getString(TAG_NAME);
                String distance = c.getString(TAG_DISTANCE);
                String distanceTrimmed = distance.substring(0,4) + " " + "miles away";

                System.out.println(name);

                // creating new HashMap
                HashMap<String, String> map = new HashMap<String, String>();

                // adding each child node to HashMap key => value
                map.put(TAG_ID, id);
                map.put(TAG_NAME, name);
                map.put(TAG_DISTANCE, distanceTrimmed);

                // adding HashList to ArrayList
                bathroomList.add(map);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }


        /**
         * Updating parsed JSON data into ListView
         * */

        ListAdapter adapter = new SimpleAdapter(this, bathroomList,
                R.layout.list_item,
                new String[] { TAG_NAME}, new int[] {
                         R.id.name });

        setListAdapter(adapter);

        // selecting single ListView item
        ListView lv = getListView();

        // Launching new screen on Selecting Single ListItem
        lv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                // getting values from selected ListItem
                //String name = ((TextView) view.findViewById(R.id.name)).getText().toString();
                //String distance = ((TextView) view.findViewById(R.id.distance)).getText().toString();


                // Starting new intent
                //Intent in = new Intent(getApplicationContext(), SeachActivity.class);
                //in.putExtra(TAG_NAME, name);
                //in.putExtra(TAG_DISTANCE, distance);
                //startActivity(in);

            }
        });


    }

}
  • 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-17T11:56:00+00:00Added an answer on June 17, 2026 at 11:56 am

    change ListView id to android:id="@android:id/list" because when you are extending ListActivity you must have ListView id android.R.id.list

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

Sidebar

Related Questions

I am getting this error: Caused by: java.lang.RuntimeException: Your content must have a ListView
am getting this exception: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}: java.lang.ClassNotFoundException: business.premium.Problemio at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
i am getting an fatal exception like java.lang.RuntimeException: Unable to start activity ComponentInfo{android/com.android.internal.app.ResolverActivity}: java.lang.SecurityException:
I am getting this error from the debugger: ERROR/AndroidRuntime(10540): Caused by: java.lang.RuntimeException: Your content
i am getting java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fb.test/com.fb.test.Fb_testActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f020005 error
I am new at Android. I am getting errors java.lang.NullPointerException and java.lang.RuntimeException application force
I'm getting this exception: 10-24 17:08:19.711: E/AndroidRuntime(1379): FATAL EXCEPTION: main 10-24 17:08:19.711: E/AndroidRuntime(1379): java.lang.RuntimeException:
i'm getting the following exception: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cs.workshop.solvedroid/cs.workshop.solvedroid.SolveCaptureActivity}: java.lang.NullPointerException when i
I am getting the following exceptions java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage/mypackage.MyActivity}: android.view.InflateException: Binary
Getting this error: java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:200) at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)

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.