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

  • Home
  • SEARCH
  • 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 7431755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:20:42+00:00 2026-05-29T09:20:42+00:00

public class HomeActivity extends Activity{ // public ArrayList<User> users1 = new ArrayList<User>(); @Override public

  • 0
public class HomeActivity extends Activity{


//   public ArrayList<User> users1 = new ArrayList<User>();
    @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

      // ListView lv = (ListView) findViewById(R.id.user_crumbs_list);

    final ArrayList<User> users1 = new ArrayList<User>();  
    User user = null;
       class AsyncLoader extends AsyncTask<User,Void, ArrayList<User>> {
           ProgressDialog dialog;

        @Override

        protected void onPreExecute(){

               dialog = new ProgressDialog(HomeActivity.this); // App - your main activity class
               dialog.setMessage("Please, wait...");
               dialog.show();
        }

        @Override
        protected ArrayList<User> doInBackground(User... users) {
            String response = "";

            for (User user:users)

                try {

                  try {
                        user = new User("4eeb34c6d80e8f1214000000");
                        user.getFollowingCrumbsUpList();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }





                    for(User u : user.following){
                        users1.add(u);
                    }



                } catch (Exception e) {
                    e.printStackTrace();
                }

        return users1;
        }

        protected void onPostExecute(String result) {
            dialog.dismiss();
            return;

        }


        }






        AsyncLoader task = new AsyncLoader();
        task.execute(user);



        setContentView(R.layout.user_main_tab_home);
        final UserFollowingListAdapter csl = new          UserFollowingListAdapter(this,R.layout.user_list_item,users1,this);
        ListView lv = (ListView) findViewById(R.id.user_list);          









       public void showError(){
        new AlertDialog.Builder(this)
        .setTitle(" Oops , Server down :( ")
        .setPositiveButton("Ok", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface arg0, int arg1) {
                // TODO Auto-generated method stub

            }
            //
        }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                // Do nothing.
            }
        }).show();

      }
}

This is going on an infinite loop where the data doesn’t load at all and the dialog goes on an infinite loop till I click on it. My goal is to load some initial amount of data and then fetch data as per the user scroll. As of now, I’m not even able to display the data.

After debugging I found out that user1 variable has no values stored in it, which I’m not able to find out why, even though the iteration is taking place.

Any clues as to where I am going wrong?

  • 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-29T09:20:43+00:00Added an answer on May 29, 2026 at 9:20 am

    I really can’t follow what you’re trying to do, but the problem likely lies in the fact that, at the time you call task.execute(user);, user is null. So the for (User user:users) in your AsyncTask has no items to iterate over.

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

Sidebar

Related Questions

public class video extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
package com.example.android.home; import android.app.Activity; import android.os.Bundle; import android.widget.*; import android.view.*; public class HomeActivity extends
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TabHost tabHost = (TabHost) findViewById(R.id.tabhostscreen_tabhost); mLocalActivityManager =
this is my activity code public class HomeActivity extends Activity { private String html
public class async extends AsyncTask<String, Integer, String>{ ProgressDialog prog; @Override protected void onPreExecute() {
public class InterruptedInput { public static void main(String[] args) { InputThread th=new InputThread(); //worker
public class abc<X extends Z> implements Iterable<X> { protected ArrayList<X> list; public Iterator<X> iterator()
public class saveButtonListener implements ActionListener{ public void actionPerformed(ActionEvent ev){ JFileChooser chooser= new JFileChooser(); String
public class PackageTabActivity extends ListActivity{ HashMap<String,Object> hm ; ArrayList<HashMap<String,Object>> applistwithicon ; private static final
public class SuperUser extends User implements Serializable{ private static final long serialVersionUID = 1L;

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.