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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:39:46+00:00 2026-06-15T05:39:46+00:00

i am Try To Receive A Data From A Web-Service Method That return a

  • 0

i am Try To Receive A Data From A Web-Service Method That return a list (of string)I’ve Create it in ASP.NET Like This

<WebMethod()> _
Public Function HelloWorld() As List(Of String)
    Dim names As New List(Of String)
    names.Add("aaa")
    names.Add("bbb")
    names.Add("ccc")
    Return names
End Function

the invoke Result like this

<string>aaa</string>
<string>bbb</string>
<string>ccc</string>

Now I need to receive This Data And put it in the Spinner

I DO …

public class MainActivity extends Activity 
{

private Spinner myspinner;
private static final String METHOD_NAME = "HelloWorld";  
private static final String NAMESPACE = "http://tempuri.org";   
private static final String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private static final String URL = "http://www.xxxxxxxxxxx.com/ws/AndroidMethods.asmx";
private String[] Values;

private void SektorDoldur()
{
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;     
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    androidHttpTransport.debug = true;
try 
    {
       androidHttpTransport.call(SOAP_ACTION, envelope);
       SoapObject response = (SoapObject) envelope.getResponse();
       Values = new String[response.getPropertyCount()];
       for(int i=0;i<response.getPropertyCount();i++)
          {     
           Values[i] = response.getPropertyAsString(i).toString();
          }      
    }
catch (Exception e)
    {
    e.printStackTrace(); 
    }
}

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    myspinner = (Spinner)findViewById(R.id.spinner1);
    new MyTask().execute();
}
public class MyTask extends AsyncTask<Void, Void, String>
{

String response = "";
public void onPreExecute() 
  {
    super.onPreExecute();
  }
    @Override
protected String doInBackground(Void... arg0)
{
       SektorDoldur();
       return "";
}
@Override
public void onPostExecute(String res)
{

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, Values);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    myspinner.setAdapter(adapter);           
}
}
}

there is an error in this Line

ArrayAdapter<String> adapter = new ArrayAdapter<String>this,android.R.layout.simple_spinner_item, Values);

in the onPostExecute Method

Can You Help Me To Do That …

  • 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-15T05:39:47+00:00Added an answer on June 15, 2026 at 5:39 am

    The constructor ArrayAdapter(MainActivity.MyTask, int, String[]) is undefined

    In this line:

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, Values);
    

    this is referring to the MyTask class, not the Context of your Activity like you are expecting. You need to pass a reference to a valid Context, for example:

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_item, Values);
    

    Addition

    HOW Can I Retrieve a list from two dimension like

    Public Class NameAndvalue
        Public name As String
        Public value As String
    End Class
    

    I need to show the name in the spinner and the value when i click at some item …

    One way is to use List<Map<String, String>> values to store each name and value in a Map and display your name Strings in the Spinner with a SimpleAdapter:

    SimpleAdapter adapter = new SimpleAdapter(this, values, 
            android.R.layout.simple_spinner_item, 
            new String[] {"name"}, new int[] {android.R.id.text});
    

    Lastly inside your onItemSelected() method you can now use the value value instead of the name value.

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

Sidebar

Related Questions

I Try To Receive Data From A Web-Service Using This Code But An Fatal-Error
I have create a web service in glassfish v3. The method I am try
i am trying to use the Asynctask method to fetch data from a web
My program use UdpClient to try to receive 27 responses from 27 hosts. The
If I try to run xcodebuild from the command line, I receive the message:
I've got a C# WCF service that passes a collection of instantiated .Net objects
I'm having issues with Unicode characters in Perl. When I receive data in from
Alright, I'm trying to set a program I have to receive data from a
I'm working on a web application that shows event logs data, similar to Event
I have a web service with just 1 Web method which will accept xml

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.