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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:57:26+00:00 2026-05-26T20:57:26+00:00

This is a follow up question from my question thread exiting error in android

  • 0

This is a follow up question from my question thread exiting error in android

I created an async task but the values do not show up in the list view….

public class History extends Activity implements OnItemClickListener
{
/** Called when the activity is first created. */
ListView list;

//LIST OF ARRAY STRINGS WHICH WILL SERVE AS LIST ITEMS
ArrayList<String> listItems;

//DEFINING STRING ADAPTER WHICH WILL HANDLE DATA OF LISTVIEW
ArrayAdapter<String> adapter;
private String resDriver,resPassenger,ID;
private ProgressDialog dialog;
ArrayList<HashMap<String, Object>> listInfo = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> item;
JSONObject jDriver;
//JSONObject jPassenger;

// Make strings for logging
private final String TAG = this.getClass().getSimpleName();
private final String RESTORE = ", can restore state";
private final String state = "Home Screen taking care of all the tabs";
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    Intent loginIntent = getIntent();
    ID = loginIntent.getStringExtra("ID");
    listItems = new ArrayList<String>();
    Log.i(TAG, "Started view active rides");
    setContentView(R.layout.searchresults);
    list = (ListView)findViewById(R.id.ListView01);
    list.setOnItemClickListener(this);
    adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,listItems);

    list.setAdapter(adapter);
    getInfo();
}
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3)
{
// TODO Auto-generated method stub
    Toast.makeText(this, "u clicked " + listItems.get(position) ,Toast.LENGTH_LONG).show();
}

public void getInfo(){

    DownloadInfo task = new DownloadInfo();
    task.execute(new String[] { "http://www.vogella.de" });

}

private class DownloadInfo extends AsyncTask<String, Void , ArrayList<String>>{

    @Override
    protected ArrayList<String> doInBackground(String ... strings) {
        ArrayList<String> listItems1;
        jDriver = new JSONObject();
        try {
            jDriver.put("ID", ID);
            jDriver.put("task", "GET DATES");

        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        listItems1 = new ArrayList<String>();
        Log.i(TAG,"Sending data for the driver rides");
        resDriver = HTTPPoster.sendJson(jDriver,"URL"); // Any Server URL

        JSONObject driver;
        try {
            driver = new JSONObject(resDriver);
            Log.i(TAG,"Recieved Driver details");
            if ( driver.getString("DATABASE ERROR").equals("False")){
                int length = Integer.parseInt( driver.getString("length"));
                Log.i(TAG,"length is " + length);
                for( int i =0 ; i< length ; i++){
                    String info = driver.getString(Integer.toString(i));
                    String[] array = info.split(",");
                    Log.i(TAG,"array is " + Arrays.toString(array));
                    Log.i(TAG,"Date "+ array.length);
                    Log.i(TAG,"DONE WITH THE LOOP");
                    //listInfo.add(item);
                    Log.i(TAG,"Date is"+array[0]);
                    listItems1.add(array[0]);                           
                }
            }
        } catch (JSONException e) {
        // TODO Auto-generated catch block
            listItems1.add("No driver rides created");
        }
        return listItems1;
    }

    @Override
    protected void onPostExecute(ArrayList<String> result) {

        listItems = result;
        adapter.notifyDataSetChanged();
    }
}
}

The problem is that the values in the adapter do not get modified…

  • 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-05-26T20:57:27+00:00Added an answer on May 26, 2026 at 8:57 pm

    You initialize your adapter with a empty listItems, after your fill your listItems in AsyncTask. onPostExecute(), your adapter is not get updated, try this:

    protected void onPostExecute(ArrayList<String> result) {
      listItems = result;
      adapter.addAll(ListItems);
      adapter.notifyDataSetChanged();
    }
    

    Hope that help.

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

Sidebar

Related Questions

This is a follow-on question from the one I asked here . Can constraints
This is a follow-up to my question from yesterday . I have Scott Meyers'
This is a follow on question to How do I delete 1 file from
This is a follow up from a question of mine that was just answered
This is a follow-on from this question, in which I was trying to suppress
This is a follow on from my previous question although this is about something
This question is a follow-up from How to indicate that a method was unsuccessful
This question is a follow on from this one ... I am binding to
So this question is a sort of follow on from here ( how to
The question is basically a follow up to this thread: Using a 64 bit

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.