Click here to Skip to main content
15,881,730 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to populate a spinner using GetAllUsers() method of my wcf web services.The method returns all users from database.I have successfully used it in web form on button click.
I want to populate spinner in xamarin android with all the users using web service.

I dont know how to do it. Unable to populate arrayadapter from data of web services.
This is my web service code for populating users:
public class ServiceSunday : IServiceSunday
   {

       public  List<Employee> GetAllEmployee()
       {
           List<Employee> employee = new List<Employee>();
           string constring = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
           SqlConnection con = new SqlConnection(constring);
           con.Open();
           string qry = "select * from EmpDetail";
           SqlCommand cmd = new SqlCommand(qry, con);

           SqlDataReader dr = cmd.ExecuteReader();
           while (dr.Read())
           {
               Employee emp = new Employee();
               emp.EmpNo = dr.GetInt32(0);
               emp.Name = dr.GetString(1);
               emp.Empcode = dr.GetString(2);
               emp.keywords = dr.GetString(3);
               emp.mobile = dr.GetString(4);

               employee.Add(emp);

           }
           con.Close();
           return employee;

       }


Please guide me how to populate spinner using array adapter.Thanks in advance
Posted

1 solution

http://docs.xamarin.com/guides/android/user_interface/spinner/[^]

Here, in given example, resource array is used but what you can do is, you can create your own ArrayList<t> and use it in adapter and use that adapter with Spinner.

If it's not working, upload your android and service code here.!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900