This section describes adding a C1ComboBox control to your Android application and displaying a list of items in the drop-down as suggestions for users.
Complete the following steps to display a C1ComboBox control.
The following image shows a C1ComboBox displaying input suggestions as the user types.
To add the C1ComboBox C1control to you layout, open the .axml file in your layout folder from the Solution Explorer and replace its code with the code below.
XML |
Copy Code |
---|---|
<?xml version="1.0" encoding="utf-8"?> <C1.Android.Input.C1AutoComplete xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/autocomplete_highlight" android:layout_width="match_parent" android:layout_height="wrap_content" /> |
Alternatively, you can drag a C1ComboBox control from the Toolbox within the custom control tab onto your layout surface in designer mode. Then, inside your activity, add the following code to initialize C1ComboBox
C# |
Copy Code |
---|---|
public class ComboBoxActivity : Activity { protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); LinearLayout layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; C1ComboBox comboBox = new C1ComboBox(this); comboBox.DisplayMemberPath = "Name"; comboBox.ItemsSource = Countries.GetDemoDataList(); layout.AddView(comboBox); comboBox.SelectedValue = new System.Object { }; Space emptySpace = new Space(this); layout.AddView(emptySpace); this.SetContentView(layout); } } public class Countries : object { public string Name { get; set; } public Countries() { this.Name = string.Empty; } public Countries(string name, double sales, double salesgoal, double download, double downloadgoal, double expense, double expensegoal, string fruits) { this.Name = name; } public static IEnumerable<object> GetDemoDataList() { List<object> array = new List<object>(); var quarterNames = "Australia,Bangladesh,Brazil,Canada,China".Split(','); for (int i = 0; i < quarterNames.Length; i++) { array.Add(new Countries { Name = quarterNames[i] }); } return array as IEnumerable<object>; } } |
Press F5 to run your application.