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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:43:51+00:00 2026-06-13T09:43:51+00:00

I’m having problems working my way through an old tutorial, essentially i’m trying to

  • 0

I’m having problems working my way through an old tutorial, essentially i’m trying to pull the data returned in JSON format from http://www.amazingjobs.co.uk/app/marc/api/candidates/ into a listview.

I literally started learning android/java 24 hours ago so its likely it may be very simple but I just can’t quite seem to figure it out, lines with errors are in bold!

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
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.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import com.google.gson.Gson;


public class Searchjobs extends Activity {
    // url to make request
    private static String url = "http://www.amazingjobs.co.uk/app/marc/api/candidates/";

    // JSON Node names
    private static final String TAG_RESULTS = "results";
    // Jobs JSONArray
    JSONArray jobs = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_searchjobs);
        Button Searchbutton = (Button) findViewById(R.id.Searchbutton);
        Searchbutton.setOnClickListener(searchClick);
    }

    private OnClickListener searchClick = new OnClickListener() {
        public void onClick(View v) {

          // Hashmap for ListView
              ArrayList<HashMap<String, String>> JobList = new ArrayList<HashMap<String, String>>();
              // Creating JSON Parser instance
              JSONParser jParser = new JSONParser();
              // getting JSON string from URL
              JSONObject json = jParser.getJSONFromUrl("http://www.amazingjobs.co.uk/app/marc/api/candidates/");
              // Getting Array of Contacts
             try {
                jobs = json.getJSONArray(TAG_RESULTS);

                for(int i = 0; i < jobs.length();i++){
                    JSONObject j = jobs.getJSONObject(i);

                    String title = j.getString("job_title");

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

                    map.put("Title", title);

                    JobList.add(map);


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

             **ListAdapter adapter = new SimpleAdapter(this, JobList,R.layout.list_item,
                        new String[] { "Title" }, new int[] {R.id.title});**
             **ERROR: The constructor SimpleAdapter(new View.OnClickListener(){}, ArrayList<HashMap<String,String>>, int, String[], int[]) is undefined**

                **setListAdapter(adapter);
The method setListAdapter(ListAdapter) is undefined for the type new View.OnClickListener(){}**

                // selecting single ListView item
                **ListView lv = getListView();**
                    **ERROR: The method getListView() is undefined for the type new View.OnClickListener(){}**


                 lv.setOnItemClickListener(new OnItemClickListener() {

                 @Override
                 public void onItemClick(AdapterView<?> parent, View view,
                         int position, long id) {

                 }
             });

        };
    };

EDIT Ok new code is below, errors are, which seems odd because the activity errors relate to an activity that definately exists, have tried restart/clean in eclipse too.

Description Resource Path Location Type
activity_searchjobs cannot be resolved or is not a field Searchjobs.java /AmazingJobs/src/app/android/amazingjobs line 47 Java Problem
activity_searchjobs cannot be resolved or is not a field Searchjobs.java /AmazingJobs/src/app/android/amazingjobs line 105 Java Problem
Searchbutton cannot be resolved or is not a field Searchjobs.java /AmazingJobs/src/app/android/amazingjobs line 48 Java Problem
list_item cannot be resolved or is not a field Searchjobs.java /AmazingJobs/src/app/android/amazingjobs line 83 Java Problem

public class Searchjobs extends ListActivity {
    // url to make request
    private static String url = "http://www.amazingjobs.co.uk/app/marc/api/candidates/";

    // JSON Node names
    private static final String TAG_RESULTS = "results";
    // Jobs JSONArray
    JSONArray jobs = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_searchjobs);
        Button Searchbutton = (Button) findViewById(R.id.Searchbutton);
        Searchbutton.setOnClickListener(searchClick);
    }

    private OnClickListener searchClick = new OnClickListener() {
        public void onClick(View v) {

          // Hashmap for ListView
              ArrayList<HashMap<String, String>> JobList = new ArrayList<HashMap<String, String>>();
              // Creating JSON Parser instance
              JSONParser jParser = new JSONParser();
              // getting JSON string from URL
              JSONObject json = jParser.getJSONFromUrl("http://www.amazingjobs.co.uk/app/marc/api/candidates/");
              // Getting Array of Contacts
             try {
                jobs = json.getJSONArray(TAG_RESULTS);

                for(int i = 0; i < jobs.length();i++){
                    JSONObject j = jobs.getJSONObject(i);

                    String title = j.getString("job_title");

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

                    map.put("Title", title);

                    JobList.add(map);


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

             ListAdapter adapter = new SimpleAdapter(getApplication(), JobList,R.layout.list_item,
                     new String[] { "Title" }, new int[] {R.id.title});

                setListAdapter(adapter);

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

                 lv.setOnItemClickListener(new OnItemClickListener() {

                 @Override
                 public void onItemClick(AdapterView<?> parent, View view,
                         int position, long id) {

                 }
             });

        };
    };
  • 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-13T09:43:52+00:00Added an answer on June 13, 2026 at 9:43 am
    ListAdapter adapter = new SimpleAdapter(this, JobList,R.layout.list_item,
                            new String[] { "Title" }, new int[] {R.id.title});
    

    should be changed to:

    ListAdapter adapter = new SimpleAdapter(getApplicationContext(), JobList,R.layout.list_item,
                            new String[] { "Title" }, new int[] {R.id.title});
    

    Second,

    ListView lv = getListView();

    will be resolved if you extend ListActivity instead of Activity.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I

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.