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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:56:02+00:00 2026-06-11T20:56:02+00:00

I want to fill a ListFragment with certain objects loaded from my MySql database.

  • 0

I want to fill a ListFragment with certain objects loaded from my MySql database.

It has to load the first 10 ‘objects’ from my ResultSet.
I want to use an AsyncTaskLoader for this and put the loaded object in a ListItem each time I retreive it from the database.

Can anybody help me with this one? Tried searching for good examples or tutorials but I haven’t really found something that’s really useful…

  • 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-11T20:56:03+00:00Added an answer on June 11, 2026 at 8:56 pm

    Create your adapter with a new list in your preexecute method. Set that adapter to your listview.

    Then in doInBackground read your database, create objects to fit in your list, but don’t add them. Pas each object after made as parameter for your publishprogress method.

    In onProgressUpdate add your object to the list and notify your adapter that the dataset is changed.

    Below is an example for how I do it reading a twitter call.

    private class parseTwitterTask extends AsyncTask<Void, TCListObject2, List<TCListObject2>> {
        TCListObjectAdapter2 adapter;
        List<TCListObject2> list;
    
        @Override
        protected void onPreExecute() {
            list = new ArrayList<TCListObject2>();
            ListView lv = (ListView)findViewById(R.id.twitterlist);
            adapter = new TCListObjectAdapter2(list);
            lv.setAdapter(adapter);
            super.onPreExecute();
        }
    
        @Override
        protected List<TCListObject2> doInBackground(Void... params) {
            try {
                String url = social.get("twittersearchurl");//"http://search.twitter.com/search.json?q=" + social.get("twitter");
                String json = Internet.request(url, null);
                JSONObject jo = new JSONObject(json);
                if(jo.has("results")) {                 
                    JSONArray ar = jo.getJSONArray("results");
                    for(int i = 0; i < ar.length(); i++) {
                        TCListObject2 tweet = new TCListObject2();
                        JSONObject jobj = (JSONObject) ar.get(i);
                        tweet.id = "false";
                        tweet.img = jobj.getString("profile_image_url");
    
                        String text = jobj.getString("text");
                        text = Html.fromHtml(text).toString();
                        tweet.params.put(R.id.sub2, text);
    
                        String name = jobj.getString("from_user");
                        name = Html.fromHtml(name).toString();
                        tweet.params.put(R.id.text, name);
    
                        String time = jobj.getString("created_at");
                        tweet.params.put(R.id.sub1, Converter.timeToTimeAgo(time));
    
                        try {
                            tweet.time = new Date(time);
                        } catch(Exception e) {
                            e.printStackTrace();
                        }
    
                        tweet.celLayout = R.layout.cell_tweetobject;
                        publishProgress(tweet);
                    }
                }
            } catch(Exception e) {
                e.printStackTrace();
            }
    
            return list;
        }
    
        @Override
        protected void onProgressUpdate(TCListObject2... values) {
            list.add(values[0]);
            adapter.notifyDataSetChanged();
            super.onProgressUpdate(values);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to fill a combobox with data from the database when the page
I want to fill jqGrid from a stored procedure, there was 1 good example
I simply want to fill-up cells in my spreadsheet from a VBA function. By
I Had Drop down list and I want to fill it with data from
I am using JSON for first time... and want to fill my datagrid with
i want to fill the data of the charts from values i have in
I want to fill the area outside a rectangle on a canvas. I use
i want to fill database table in wxListCtrl, i can do this , i
Hi I want to Fill out a Rectangle. Normally i can use: g.FillRectangle(Brushes.Green, x1,
I want to fill items in a combobox, each of them has different behaviour.

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.