diff options
author | Samantha Houts <samhouts@users.noreply.github.com> | 2017-05-23 10:58:19 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2017-05-23 10:58:19 -0700 |
commit | 877905611c0ba6bb8551dd665f528a970e354274 (patch) | |
tree | fb345569d7b5eaf2b5fd004068356d32c7c526f2 /Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs | |
parent | b934308f629f244de463046c62c7b41fe6ffc5f8 (diff) | |
download | xamarin-forms-877905611c0ba6bb8551dd665f528a970e354274.tar.gz xamarin-forms-877905611c0ba6bb8551dd665f528a970e354274.tar.bz2 xamarin-forms-877905611c0ba6bb8551dd665f528a970e354274.zip |
[Android] Support up to 20 templates, as documented. (#929)
* Add repro for 42956
* [Android] Support up to 20 templates, as documented.
* Spaces -> tabs
* A little more info on the _dataTemplateIncrementer
* Fix test case number
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs index 17c7ffa7..b577ec1c 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs @@ -25,7 +25,12 @@ namespace Xamarin.Forms.Platform.Android protected readonly ListView _listView; readonly AListView _realListView; readonly Dictionary<DataTemplate, int> _templateToId = new Dictionary<DataTemplate, int>(); - int _dataTemplateIncrementer = 2; // lets start at not 0 because + int _dataTemplateIncrementer = 2; // lets start at not 0 because ... + + // We will use _dataTemplateIncrementer to get the proper ViewType key for the item's DataTemplate and store these keys in _templateToId. + // If an item does _not_ use a DataTemplate, then the ViewType key will be DefaultItemTemplateId (1) or DefaultGroupHeaderTemplateId (0). + // To prevent a conflict in the event that a ListView supports both templates and non-templates, we will start the DataTemplate key at 2. + int _listCount = -1; // -1 we need to get count from the list Cell _enabledCheckCell; @@ -109,7 +114,13 @@ namespace Xamarin.Forms.Platform.Android public override int ViewTypeCount { - get { return 20; } + get + { + // We have a documented limit of 20 templates on Android. + // ViewTypes are selected on a zero-based index, so this count must be at least 20 + 1. + // Plus, we arbitrarily increased the index of the DataTemplate index by 2 (see _dataTemplateIncrementer). + return 23; + } } public override bool AreAllItemsEnabled() |