Bug 23116 - Android - Picker control, blank item list issue
Summary: Android - Picker control, blank item list issue
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.3
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-09-17 19:45 UTC by Rob
Modified: 2015-05-27 00:28 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Screen shot of the issue from an Asus memopad (27.87 KB, image/png)
2014-09-18 11:32 UTC, Rob
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Rob 2014-09-17 19:45:04 UTC
If you add a blank item to the top of a list pic.Items.Add(string.empty) and show the list a 0 is presented as the first option not the empty string.
Move the list and it self corrects.
Tested on Android only.
Comment 1 Sadik Ali 2014-09-18 09:42:06 UTC
I try to reproduce this issue but unable to reproduce this. 

Steps I have followed:

1. Create an Xamarin.Forms Application
 New Solution=>C#=>MobileApps=>Blank App(Xamarin.Forms Portable)
2. Add a class file
 PCL=>Add=>NewFile=>General=>EmptyClass give name "BasicListPage"=>click New
3.Add following code to "BasicListPage.cs"

    var listView = new ListView ();
    string text = string.Empty;
    listView.ItemsSource = new [] {text, "a", "b", "c","d","E"};
    Padding = new Thickness (0,20,0,0);
    Content = listView;

4. Call "BasicListPage.cs" in App.cs
    return new BasicListPage ();

5. Observe the top item of list that is empty string not zero

Could you please provide us a sample application and environment info?
That will be helpful to reproduce this issue at our end. 

You can get Environment info from here:
Xamarin Studio:
Main menu=>Help=>About=>Show Details=>Copy Information
Visual Studio:
Main Menu=>Help=>About Microsoft Visual studio=>Copy Info

Screencast:http://www.screencast.com/t/MuvVcbUt

Environment info:

=== Xamarin Studio ===

Version 5.3 (build 441)
Installation UUID: a7e29e93-6348-4126-9ebc-b2777c96a552
Runtime:
	Microsoft .NET 4.0.30319.18408
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.16.0 (Business Edition)
Android SDK: E:\android-sdk
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)

=== Build Information ===

Release ID: 503000441
Git revision: befb6aa1176d37a5f678f4274f340a0159091b7a
Build date: 2014-09-08 20:54:12-04
Xamarin addins: 6dc7c388e31fdfc8014689839d37de0d4622435c

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 2 Rob 2014-09-18 11:32:54 UTC
Created attachment 8106 [details]
Screen shot of the issue from an Asus memopad

The attached screen shot was takeN from a Asus Memopad running KitKat

--------------------------------------------------------
PAGE XAML
<Picker x:Name="picTitle" Grid.Column="1" />

--------------------------------------------------------
PAGE CODE BEHIND
CommonLists cl = new CommonLists();
picTitle.Items.Add(string.Empty);
foreach (string title in cl.NameTitles)
picTitle.Items.Add(title);

--------------------------------------------------------
AND THE LIST GENERATOR
private string[] _NameTitles = null;
public IEnumerable<string> NameTitles
{
   get
   {
      if (_NameTitles == null)
      {
         _NameTitles = new string[]
            {"Mr", "Mrs", "Miss", "Ms", "Dr", "Lord", "Rev", "Cllr" };
      }
      return _NameTitles.AsEnumerable<string>();
   }
}


--------------------------------------------------------
XAMARIN STUDIO INFO
=== Xamarin Studio ===

Version 5.3 (build 441)
Installation UUID: 9f27859d-5fe5-4ae6-8a73-c2a9857293cc
Runtime:
	Microsoft .NET 4.0.30319.34014
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.16.0 (Business Edition)
Android SDK: C:\Users\Rob\AppData\Local\Android\android-sdk
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode, sharing)

=== Build Information ===

Release ID: 503000441
Git revision: befb6aa1176d37a5f678f4274f340a0159091b7a
Build date: 2014-09-08 20:54:12-04
Xamarin addins: 6dc7c388e31fdfc8014689839d37de0d4622435c

=== Operating System ===

Windows 6.2.9200.0 (64-bit)




--------------------------------------------------------
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

LightSwitch for Visual Studio 2013   06177-179-0512733-02390
Microsoft LightSwitch for Visual Studio 2013

Team Explorer for Visual Studio 2013   06177-179-0512733-02390
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-179-0512733-02390
Microsoft Visual Basic 2013

Visual C# 2013   06177-179-0512733-02390
Microsoft Visual C# 2013

Visual C++ 2013   06177-179-0512733-02390
Microsoft Visual C++ 2013

Visual F# 2013   06177-179-0512733-02390
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-179-0512733-02390
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-179-0512733-02390
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools   12.3.50717.0
Microsoft Web Developer Tools contains the following components:
Support for creating and opening ASP.NET web projects
Browser Link: A communication channel between Visual Studio and browsers
Editor extensions for HTML, CSS, and JavaScript
Page Inspector: Inspection tool for ASP.NET web projects
Scaffolding: A framework for building and running code generators
Server Explorer extensions for Microsoft Azure Websites
Web publishing: Extensions for publishing ASP.NET web projects to hosting providers, on-premises servers, or Microsoft Azure

ASP.NET Web Frameworks and Tools 2012.2   4.1.21001.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.20703.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.2
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GhostDoc   4.9.14150.0
GhostDoc automatically generates XML documentation comments.

InstallShield Limited Edition   
InstallShield. For more information visit the Flexera Software website at <http://www.FlexeraSoftware.com>. Copyright © 2013 Flexera Software LLC. All Rights Reserved.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone
Build 

Microsoft Azure Mobile Services Tools   1.2
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.4
Microsoft Azure Tools for Microsoft Visual Studio 2013 - v2.4.20730.1601

NuGet Package Manager   2.8.50313.46
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Office Developer Tools for Visual Studio 2013 ENU   12.0.30626
Microsoft Office Developer Tools for Visual Studio 2013 ENU

PowerShell Tools   1.2
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   12.0.40706.0
Microsoft SQL Server Data Tools

Windows Azure Tools   2.2
Windows Azure Tools for Microsoft Visual Studio 2013 - v2.2.11003.1601

Windows Azure Tools   2.3
Windows Azure Tools for Microsoft Visual Studio 2013 - v2.3.20320.1602

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   3.5.58.0 (6b70b1e28c5a733187f7659220da4c0ff61ab2b1)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android
Comment 3 Andy Hopper 2014-09-30 14:58:41 UTC
I have a related issue: if you Clear the Items list and set SelectedIndex to -1, you see a 0 as the only item in the list. Selecting this item results in a crash with the below log:

09-30 14:56:41.907 I/MonoDroid( 2289): UNHANDLED EXCEPTION:
09-30 14:56:41.907 I/MonoDroid( 2289): System.ArgumentOutOfRangeException: Argument is out of range.
09-30 14:56:41.907 I/MonoDroid( 2289): Parameter name: index
An unhandled exception occured.

09-30 14:56:41.907 I/MonoDroid( 2289): at System.Collections.Generic.List`1<string>.get_Item (int) <0x0005b>
09-30 14:56:41.907 I/MonoDroid( 2289): at System.Collections.ObjectModel.Collection`1<string>.get_Item (int) <0x0004c>
09-30 14:56:41.907 I/MonoDroid( 2289): at Xamarin.Forms.Platform.Android.PickerRenderer/<>c__DisplayClass4.<OnClick>b__3 (object,Android.Content.DialogClickEventArgs) <IL 0x0003c, 0x000db>
09-30 14:56:41.907 I/MonoDroid( 2289): at Android.Content.IDialogInterfaceOnClickListenerImplementor.OnClick (Android.Content.IDialogInterface,int) [0x0000d] in /Users/builder/data/lanes/1131/2a7b6821/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Content.IDialogInterface.cs:226
09-30 14:56:41.907 I/MonoDroid( 2289): at Android.Content.IDialogInterfaceOnClickListenerInvoker.n_OnClick_Landroid_content_DialogInterface_I (intptr,intptr,intptr,int) [0x00011] in /Users/builder/data/lanes/1131/2a7b6821/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Content.IDialogInterface.cs:180
09-30 14:56:41.907 I/MonoDroid( 2289): at (wrapper dynamic-method) object.76e195b6-3918-4295-93bd-5e1993f12631 (intptr,intptr,intptr,int) <IL 0x0001d, 0x00027>
09-30 14:56:41.907 D/Mono    ( 2289): Found as '__android_log_print'.
Comment 4 Rajneesh Kumar 2014-10-01 11:15:55 UTC
I have checked this issue and able to reproduce this issue. To reproduce this issue I have followed the instruction provided in Comment 2.

Steps I have followed:

1. Create a Xamarin.forms Portable application in XS
2. Add a XAML page named "MyPage.xaml"
3. Add Following code to "MyPage.xaml"
      <Picker x:Name="picTitle" Grid.Column="1" />
4. Add following code to the "MyPage.xaml.cs"

   public partial class MyPage : ContentPage
	{	
	public MyPage ()
	{
	InitializeComponent ();
	CommonLists cl = new CommonLists();
	picTitle.Items.Add(string.Empty);
	foreach (string title in cl.NameTitles)
	picTitle.Items.Add(title);
	}

	}
	class CommonLists
	{
	private string[] _NameTitles = null;
	public IEnumerable<string> NameTitles
	{
	get
	 {
	   if (_NameTitles == null)
	    {
	     _NameTitles = new string[]
	     {"Mr", "Mrs", "Miss", "Ms", "Dr", "Lord", "Rev", "Cllr" };
	     }
	   return _NameTitles.AsEnumerable<string>();
	  }
         }
	}

5. Call "MyPage" in App.cs
6. Run the application an observe that the list a 0 is presented as the first option not the empty string.

Screencast: http://www.screencast.com/t/hlGz0nd4Z28

Environment Info:
=== Xamarin Studio ===

Version 5.4 (build 240)
Installation UUID: a7e29e93-6348-4126-9ebc-b2777c96a552
Runtime:
	Microsoft .NET 4.0.30319.18408
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.16.0 (Business Edition)
Android SDK: E:\android-sdk
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_39
java version "1.6.0_39"
Java(TM) SE Runtime Environment (build 1.6.0_39-b04)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode)

=== Build Information ===

Release ID: 504000240
Git revision: 01786bc67c7024ec33d327ed27e4416d7a846f4e
Build date: 2014-09-17 11:05:20-04
Xamarin addins: 7cd7dfcd6b7b7b53281508954ec080f1cd153ad3

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 5 Jason Smith [MSFT] 2015-05-27 00:28:07 UTC
This seems to be an issue with the underlying toolkit, you should not try to insert a blank item into the list.