Now that our latest build with Xamarin support is out, some of our customers had this question:

1. In your demo, you used NameValue as datasource, but it only generates two columns data, how do I produces more column? 

Well, basically the idea is to provide a class that inherits from Java.Lang.Object as the dataprovider to the grid, and expose its properties to the ACW using getters and exporting them.

Example:



    public class Employee : Java.Lang.Object
    {
        public string Name = "";
        public string PhoneNumber ="";
        public string Title ="";
        public string Address ="";

        [Java.Interop.Export("getName")]
        public string getName(){
            return this.Name;
        }
        [Java.Interop.Export("getPhoneNumber")]
        public string getPhoneNumber(){
            return this.PhoneNumber;
        }
        [Java.Interop.Export("getTitle")]
        public string getTitle(){
            return this.Title;
        }
        [Java.Interop.Export("getAddress")]
        public string getAddress(){
            return this.Address;
        }
    }

 

 

If you do this, you should be able to use the following XML and see the results:

      <column
          dataField="Name"
          headerText="Name" />
      <column
          dataField="PhoneNumber"
          headerText="PhoneNumber" />
    </columns>

 

 

Full code is attached to this post.

grid_config.xml (570.00 bytes)

MainActivity.cs (3.93 kb)