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

The Archive Base Latest Questions

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

I am having trouble with my ArrayAdapter now… I get the error The constructor

  • 0

I am having trouble with my ArrayAdapter now… I get the error “The constructor ArrayAdapter(VideoPlay.ShowTitlesTask, int, int, ArrayList) is undefined.” What am I doing wrong?

The problem is in the class ShowTitlesTask

package com.aer.illbehonest;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JSONSerializer;

import org.apache.commons.io.IOUtils;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class VideoPlay extends Activity {   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_play);

        new ShowTitlesTask().execute("");
    }

    class ShowTitlesTask extends AsyncTask<String, Void, ArrayList<String>> {

    ArrayList<String> titlesList;

    @Override
protected ArrayList<String> doInBackground(String... args) {

    URL jsonURL = null;
    try {
           jsonURL = new URL("http://gdata.youtube.com/feeds/api/users/illbehonest/uploads?v=2&alt=jsonc");
        } catch (MalformedURLException e3) {
            e3.printStackTrace();
        }
            URLConnection jc = null;
            try {
                jc = jsonURL.openConnection();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
            InputStream is = null;
            try {
                is = jc.getInputStream();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
            String jsonTxt = null;
            try {
                jsonTxt = IOUtils.toString(is);
            } catch (IOException e) {
                e.printStackTrace();
            }

            JSONObject json = (JSONObject) JSONSerializer.toJSON(jsonTxt);

            JSONObject jdata = json.getJSONObject("data");

            JSONArray jentry = jdata.getJSONArray("items");
            for (int entryNumber = 0; entryNumber<=25; entryNumber++){
                    JSONObject entry = jentry.getJSONObject(entryNumber);
                    titlesList.add(entry.getString("title"));
            }

            return titlesList;
    }
    protected void onPostExecute(ArrayList<String> result) {
        ListView listView = (ListView)VideoPlay.this.findViewById(R.id.videolist);

        ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
                android.R.layout.simple_list_item_1, android.R.id.text1, titlesList);
        titlesList.setAdapter(arrayAdapter);
        }
    }
}
  • 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-17T06:10:39+00:00Added an answer on June 17, 2026 at 6:10 am

    you will need to return an ArrayList from doInBackground and add ArrayList to ListView in onPostExecute because this method call when doInBackground execution completes. create your AsyncTask as :

       private class GetTitlesTask extends AsyncTask<String, Void, ArrayList<String>> {
       Activity activity;
            ArrayList<String> titlesList;
           public GetTitlesTask(Activity activity){
               this.activity=activity;
           }
              @Override
              protected void onPreExecute() {
                // show progress bar here
              }
            @Override
            protected ArrayList<String> doInBackground(String... args) {
    
                 titlesList=new ArrayList<String>;
    
                  // get titles here and add to titlesList ArrayList
    
                 return titlesList; //<< return titlesList ArrayList
             }
            @Override
             protected void onPostExecute(ArrayList<String> result) {
    
                // set result ArrayList as datasouce to Adapter here
                 ListView listview=
                    (ListView)activity.findViewById(R.id.videolist);
             }
         }
    

    and start this GetTitlesTask AsyncTask from UI as:

    new GetTitlesTask(Your_Current_Activity.this).execute("");
    

    to known more about AsyncTask see

    http://developer.android.com/reference/android/os/AsyncTask.html

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

Sidebar

Related Questions

having trouble with handling a java.lang.OutOfMemoryError: bitmap size exceeds VM budget error. The original
Having trouble with using ternary operator. ... char symbol = str_base[i]; int count =
Having trouble to get a very basic version of SecKeySign() to work (I.e. porting
Having trouble with iterator. It need to iterate over ArrayList and find any other
Well it seem i am having quite some trouble with my arrayadapter of strings.
Having trouble with this jQuery function: $(#content).siblings().each(function(i){ heightOfSiblings = heightOfSiblings + this.outerHeight(); }); Error
Having trouble using libstatgrab -- I receive the following error at compile time: libstatgrabTest.cpp:16:
Having trouble trying to get this simplified. Still somewhat new to jQuery so please
Having trouble writing the bit operations to convert an int to a short depending
Having trouble with Grails Domain Classes. I am overriding the constructor to build the

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.