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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:26:32+00:00 2026-05-23T13:26:32+00:00

I have 2 spinner, each spinner’s data loaded from database using AsyncTask i call

  • 0

I have 2 spinner,
each spinner’s data loaded from database using AsyncTask

i call the AsyncTasks using this

new PopulateSpinnerA().execute();

it works if i only call one AsyncTask for one Spinner

BUT!

i have 2 Spinners, so i call the AsyncTask for each Spinner like this

new PopulateSpinnerA().execute(); // for Spinner A
new PopulateSpinnerB().execute(); // for Spinner B

I run it and my app force close

solution?

UPDATE!

i get inspiration from someone below who answer with true and false

im using a boolean (playing with true and false) to make my two spinners generated

first i make a boolean variable

Boolean SPN = false;

then i make a function to check the boolean and put it on onCreate() function

private void cek(){
        if(!SPN){
            new populateSpinnerA().execute();
        }
        if(SPN){
            new populateSpinnerB().execute();
        }
    }

on populateSpinnerA() i just put this 2 lines to run the second spinner’s AsyncTask

SPN = true;
cek();

and

BOOM!

it’s done 😀

  • 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-23T13:26:33+00:00Added an answer on May 23, 2026 at 1:26 pm

    You can not have two spinner at a time. Need to use any trick in this case,

    1. Use only one spinner.
    2. Start the spinner while initiating first spinner.
    3. Use one common flag set on PostExecute.
    4. Before step#3, on postExecute of both AsyncTask check the flag is already set, if yes just cancel the spinner.

    Refer below pseudo code.

    postExecute(){
          If(taskCompletedFlag == true){
                //Code to cancel the spinner.
                taskCompletedFlag = false;
          }else{
                taskCompledtedFlag = true;
          }
    }
    

    P.S. – In case you are not aware which AsyncTask will initiate first, you can use same mechanism over there.

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

Sidebar

Related Questions

I have a listview which loads its data from sqlite database. Each row in
I have a spinner set up like this: ArrayAdapter<String> states = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,
I have a Spinner Control bind with data from Sqllite during the Page Load
I have a selection for some items using a spinner widget. At the moment
I have an android spinner that's populated by a list of strings using an
I use this code to generate a spinner in my app: subCatAdapter = new
I have the following code populating a spinner, JSONObject jsonResponse = new JSONObject(new String(buffer));
I have a spinner and when the user selects I want to call another
I have a settings class. In this class I have a spinner, with 4
JSpinner waitHr = new JSpinner(); waitHr.setEnabled(false); I have a spinner and I need to

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.