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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:37:04+00:00 2026-06-10T06:37:04+00:00

I have been coding for JSON parsing all things are right but in logcat

  • 0

I have been coding for JSON parsing all things are right but in logcat following error is shown

08-27 10:25:49.628: E/AndroidRuntime(816): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mokshya.hosprsing/com.mokshya.hosprsing.HomeActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

following is my main code

package com.mokshya.hosprsing;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Bundle;
import android.app.ListActivity;
import android.view.Menu;
import android.widget.ArrayAdapter;

public class HomeActivity extends ListActivity {


@SuppressWarnings({"rawtypes","unchecked"})
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    setListAdapter(new ArrayAdapter (this,     android.R.layout.simple_list_item_1,this.fetchHosTime()));
}
public ArrayList<String> fetchHosTime(){
    ArrayList<String> listitems=new ArrayList<String>();
    try {
        URL hos=new URL("http://ldsclient.com/ftp/strtojson.php");
        URLConnection tc=hos.openConnection();
        BufferedReader in=new BufferedReader(new     InputStreamReader(tc.getInputStream()));
        String line;
        while((line=in.readLine())!=null) {
            JSONArray ja=new JSONArray(line);
                for(int i=0; i<ja.length();i++) {
                    JSONObject jo=(JSONObject) ja.get(i);
                    listitems.add(jo.getString("text"));

                }
        }
    }
    catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return listitems;
}


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
 }

below is my main.xml code

<ListView android:id="@android:id/list" 
    android:layout_height="fill_parent"
    android:layout_width="wrap_content"></ListView>

</RelativeLayout>
  • 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-10T06:37:06+00:00Added an answer on June 10, 2026 at 6:37 am

    Place this ListView in your main.xml

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

    See this existing answer. And, have a look at ListActivity tutorial for more help

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

Sidebar

Related Questions

Im very new to all coding including jquery. I though this would have been
I have been coding for a while now but just can't seem to get
i have been coding below. But i find another method secand part . which
I have been coding regurlarly in C++ in the past months. I am getting
Ive never heard of this before, and I have been coding in PHP for
I've been coding a very sizable project and I have run into trouble with
I've been coding in Java for the past year, and i think I have
In our company's coding standard, we have been told to be aware of the
I am 2 days old with python and coding in general, I have been
I have been coming across these two words more often but i didn't see

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.