如何使用wcf Web服务在xamarin android中填充微调器? [英] How to populate spinner in xamarin android using wcf web services?

查看:61
本文介绍了如何使用wcf Web服务在xamarin android中填充微调器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用我的wcf web服务的GetAllUsers()方法填充一个微调器。该方法从数据库返回所有用户。我已经成功地在网页上单击按钮使用它。

我想要用所有使用网络服务的用户填充xamarin android中的微调器。



我不知道怎么做。无法从网络服务数据中填充arrayadapter。

这是我用于填充用户的网络服务代码:

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

推荐答案

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



这里,在给定的示例中,使用资源数组,但您可以做的是,您可以创建自己的ArrayList< t>并在适配器中使用它并将该适配器与Spinner一起使用。



如果它不起作用,请在此处上传您的Android和服务代码。!
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.!


这篇关于如何使用wcf Web服务在xamarin android中填充微调器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆