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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:36:12+00:00 2026-06-09T09:36:12+00:00

I’m getting some error. I know what is the problem but I don’t know

  • 0

I’m getting some error. I know what is the problem but I don’t know how to fix it.

I’ve 4 spinner. Every spinner related one asynctask. For short, When I select one item on spinner1 , execute second asynctask that populate spinner2 (selected item add to second asynctask as parameter) Continues in this way.

But before end of first asynctask, spinner2 can’t populate. In this case I’m getting error. How to fix it ? How to make when first task finish, second task work ?

Here is the code;

First task

public class ilceDoldur extends AsyncTask<String[],String[],String[]>{

        @Override
        protected String[] doInBackground(String[]... params) {
            SoapObject request = new SoapObject(NAMESPACE, "ILCEGetir");
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;     
            envelope.setOutputSoapObject(request);
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.debug = true;

           try {

           androidHttpTransport.call("http://tempuri.org/ILCEGetir", envelope);
           SoapObject response = (SoapObject) envelope.getResponse();
           ilceList = new String[response.getPropertyCount()];

          for(int i=0;i<response.getPropertyCount();i++){          
                   ilceList[i] = response.getPropertyAsString(i).toString().trim();    
          }      
    } 
            catch (Exception e) {           
                e.printStackTrace();
           }    
            return ilceList;
        }

        protected void onPostExecute(String[] ilceList){
            ilceSpinner = (Spinner) findViewById(R.id.spinner1);
            ArrayAdapter<String> ilce_adapter = new ArrayAdapter<String>(NormalAnasayfa.this,android.R.layout.simple_spinner_item, ilceList);
            ilce_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            ilceSpinner.setAdapter(ilce_adapter);
            kontrol=true;
        }
    }

Second Task

public class semtDoldur extends AsyncTask<String,String[],String[]>{

        @Override
        protected String[] doInBackground(String... ParamIlce) {
            PropertyInfo ilce = new PropertyInfo();
            ilce.name= "ilce";
            ilce.setValue(ParamIlce);
            ilce.type = PropertyInfo.STRING_CLASS;

            SoapObject request = new SoapObject(NAMESPACE, "SEMTGetir");
            request.addProperty(ilce);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.bodyOut=request;
            envelope.dotNet = true; 
            envelope.setOutputSoapObject(request);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.debug = true;

           try {

           androidHttpTransport.call("http://tempuri.org/SEMTGetir", envelope);
           SoapObject response = (SoapObject) envelope.getResponse();
           semtList = new String[response.getPropertyCount()];

          for(int i=0;i<response.getPropertyCount();i++){          
                   semtList[i] = response.getPropertyAsString(i).toString().trim();    
          }      
    } 
            catch (Exception e) {           
                e.printStackTrace();
           }
            return semtList;
        }

        protected void onPostExecute(String[] semtList){
            semtSpinner = (Spinner) findViewById(R.id.spinner2);
            ArrayAdapter<String> semt_adapter = new ArrayAdapter<String>(NormalAnasayfa.this, android.R.layout.simple_spinner_item, semtList);
            semt_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            semtSpinner.setAdapter(semt_adapter);
            kontrol=true;
        }
    }

onCreate()

new ilceDoldur().execute();

        if(kontrol==true){
            kontrol=false;
            ilceSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

                public void onItemSelected(AdapterView<?> arg0, View arg1,
                        int arg2, long arg3) {
                    secilenIlce = ilceSpinner.getSelectedItem().toString().trim();
                    new semtDoldur().execute(secilenIlce);
                }
                public void onNothingSelected(AdapterView<?> arg0) {}
            });
        }

Edit:
I get data from my web service and populate spinner1. Where the data(spinner1 selected item) will I get? and Where I populate spinner2 execute second task?

  • 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-09T09:36:15+00:00Added an answer on June 9, 2026 at 9:36 am

    I find solution!

    get data from web service:

    private void ilceDoldur(){
            SoapObject request = new SoapObject(NAMESPACE, "ILCEGetir");
            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.dotNet = true;     
            envelope.setOutputSoapObject(request);
            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.debug = true;
    
           try {
    
           androidHttpTransport.call("http://tempuri.org/ILCEGetir", envelope);
           SoapObject response = (SoapObject) envelope.getResponse();
           ilceList = new String[response.getPropertyCount()];
    
          for(int i=0;i<response.getPropertyCount();i++){          
                   ilceList[i] = response.getPropertyAsString(i).toString().trim();    
          }      
    } 
            catch (Exception e) {           
                e.printStackTrace();
           }    
        }
    

    my AsyncTask:

    public class ilceDoldur extends AsyncTask<String,String[],String[]>{
    
            @Override
            protected String[] doInBackground(String... params) {
                ilceDoldur();
                return ilceList;
            }
    
            protected void onPostExecute(String[] ilceList){
                ilceSpinner = (Spinner) findViewById(R.id.spinner1);
                ArrayAdapter<String> ilce_adapter = new ArrayAdapter<String>(NormalAnasayfa.this,android.R.layout.simple_spinner_item, ilceList);
                ilce_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                ilceSpinner.setAdapter(ilce_adapter);
                ilceSecildi();
                }    
            }
    

    Get spinner1 selected item and start second asynctask:

    public String ilceSecildi(){
            ilceSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    
                public void onItemSelected(AdapterView<?> arg0, View arg1,
                        int arg2, long arg3) {
                    secilenIlce = ilceSpinner.getSelectedItem().toString().trim();
                    new semtDoldurAsync(secilenIlce).execute();
                }
                public void onNothingSelected(AdapterView<?> arg0) {}
            });
            return secilenIlce;
        }
    

    execute first task in onCreate:

    new ilceDoldur().execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is 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.