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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:16:25+00:00 2026-05-29T05:16:25+00:00

I was using the code from the doInBackground section to load a custom listview

  • 0

I was using the code from the doInBackground section to load a custom listview from a database and now that I have added it to an AsynchTask it shows nothing when the dialog has been dismissed. Does anyone know what I am doing wrong so that it will display my list when the progress bar dismisses again:

private class LoadList extends AsyncTask<String, UserRecord, JSONArray> {
     protected JSONArray doInBackground(String... link) {
        //http post
        try{
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://wallpaperapp.x10.mx/new.php");
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
        }catch(Exception e){
            Log.e("log_tag", "Error in http connection"+e.toString());
        }

        //convert response to string
        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
            sb = new StringBuilder();
            sb.append(reader.readLine() + "\n");

            String line="0";
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            result=sb.toString();
        }catch(Exception e){
            Log.e("log_tag", "Error converting result "+e.toString());
        }

        try{
            jArray = new JSONArray(result);
            JSONObject json_data=null;

            displayname = new String[jArray.length()];
            song_name = new String[jArray.length()];
            artist = new String[jArray.length()];
            description = new String[jArray.length()];
            genre = new String[jArray.length()];
            custom_genre = new String[jArray.length()];
            album = new String[jArray.length()];
            timestamp = new String[jArray.length()];
            song_id  = new int[jArray.length()];
            avatar = new String[jArray.length()];
            drawable = new Drawable[jArray.length()];
            test_rating = new Float[jArray.length()];
            songurl = new String[jArray.length()];

            for(int i=0;i<jArray.length();i++){
                json_data = jArray.getJSONObject(i);
                song_id[i]=json_data.getInt("id");
                song_name[i]=json_data.getString("songname");
                artist[i]=json_data.getString("artist");
                displayname[i]=json_data.getString("displayname");
                description[i]=json_data.getString("description");
                genre[i]=json_data.getString("genre");
                custom_genre[i]=json_data.getString("customgenre");
                album[i]=json_data.getString("album");
                timestamp[i]=json_data.getString("format");
                avatar[i]=json_data.getString("image_url");
                songurl[i]=json_data.getString("song_url");
                drawable[i] = LoadImageFromWebOperations(avatar[i]);
                test_rating[i] = (float) json_data.getDouble("rating");
                user5  = new UserRecord(genre[i], displayname[i], timestamp[i], drawable[i], test_rating[i], songurl[i]);

                publishProgress(user5);

            }
        }
        catch(JSONException e1){
            Toast.makeText(getBaseContext(), "No results found." ,Toast.LENGTH_LONG).show();

        } catch (ParseException e1) {
            e1.printStackTrace();
        }           

         return null;
     }

     protected void onProgressUpdate(UserRecord... progress) {
         users.add(user5);

     }

     protected void onPostExecute(JSONArray jArray) {
         dialog.dismiss();
     }

     protected void onPreExecute(){
         dialog = ProgressDialog.show(mainmenu.this, "", 
                 "Loading. Please wait...", true);
     }
}

Here is my onCreate:

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

    nameValuePairs = new ArrayList<NameValuePair>();
    users = new ArrayList<UserRecord>();                

    ListView listView = (ListView) findViewById(R.id.ListViewId);

    songname = (TextView) findViewById(R.id.tvTrack);
    songimage = (ImageView) findViewById (R.id.imageView1);
    playbutton = (Button) findViewById (R.id.playbutton1);
    downloadbutton = (Button) findViewById (R.id.downloadbutton3);
    listView.setAdapter(new UserItemAdapter(this, android.R.layout.simple_list_item_1, users));
    flipper = (ViewFlipper) findViewById(R.id.tab2); 
    //when a view is displayed
    flipper.setInAnimation(this,android.R.anim.fade_in);
    //when a view disappears
    flipper.setOutAnimation(this, android.R.anim.fade_out);

    screenWidth = getResources().getDisplayMetrics().widthPixels;
    new LoadList().execute();
            }

The UserRecord that is getting published:

public class UserRecord {
    public String genrez;
    public String displaynamez;
    public String timestampz;
    public Drawable image_urlz;
    public Float test_ratingz;
    public String songurlz;

    public UserRecord(String genrez, String displaynamez, String timestampz, Drawable image_urlz, Float test_rating, String songurlz) {
        this.genrez = genrez;
        this.displaynamez = displaynamez;
        this.timestampz = timestampz;
        this.image_urlz = image_urlz;
        this.test_ratingz = test_rating;
        this.songurlz = songurlz;

    }
}
  • 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-29T05:16:26+00:00Added an answer on May 29, 2026 at 5:16 am
     @Override
    protected void onPostExecute(String result) {
        dialog.dismiss();
    
    }
    

    please put listview code in this function, means binding data to listview

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

Sidebar

Related Questions

My main solution is using code from a utility class library, that I wrote
I have a listview that's populated by rows that get their data from a
Using code from open source MusicDroid with the following code that I found during
I have ported some code from Mingw which i wrote using code::blocks, to visual
I'm working on a project that is using code from an OpenSource project. One
I tried writing an app that samples the microphone using code from http://code.google.com/p/ios-coreaudio-example/ (Core
I am attempting to construct my own date picker using code from several sources.
I am attempting to construct my own date picker using code from several sources.
I'm using this code from Microsoft to play audio notifications for my application. It's
I'm using some code from here to determine when determining when the last finger

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.