Bug 38053 - Long pressing on label in ListView Header crashes (Android)
Summary: Long pressing on label in ListView Header crashes (Android)
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-01-26 14:41 UTC by Caan Mee
Modified: 2017-06-19 16:18 UTC (History)
2 users (show)

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

Sample project for crash on android (289.42 KB, application/x-zip-compressed)
2016-01-26 16:36 UTC, Caan Mee

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:

Description Caan Mee 2016-01-26 14:41:27 UTC
I have a Label in a ListView's Header, when longpressing the Label's text the app crashes:

System.NullReferenceExceptionObject reference not set to an instance of an object

  at Xamarin.Forms.Platform.Android.CellAdapter.HandleContextMode (Android.Views.View view, Int32 position) <0xd80ba9b0 + 0x001f7> in <filename unknown>:0 
  at Xamarin.Forms.Platform.Android.CellAdapter.OnItemLongClick (Android.Widget.AdapterView parent, Android.Views.View view, Int32 position, Int64 id) <0xd80ba818 + 0x0006b> in <filename unknown>:0 
  at Android.Widget.AdapterView+IOnItemLongClickListenerInvoker.n_OnItemLongClick_Landroid_widget_AdapterView_Landroid_view_View_IJ (IntPtr jnienv, IntPtr native__this, IntPtr native_parent, IntPtr native_view, Int32 position, Int64 id) <0xd80ba778 + 0x00091> in <filename unknown>:0 
  at (wrapper dynamic-method) System.Object:a935b9ed-9547-4922-ae8f-1ea2c25b71ed (intptr,intptr,intptr,intptr,int,long)

Verified on Emulator with Android 5.1 using Xamarin.Forms 2.1.0-pre2
Comment 1 Paul DiPietro [MSFT] 2016-01-26 15:20:04 UTC
A reproduction project would be appreciated in helping to investigate the issue.
Comment 2 Caan Mee 2016-01-26 16:35:31 UTC
Sorry, of course. Here you go:

1) Compile & Launch Android app
2) Longpress the Label in the Header
3) App crashes with the above mentioned exception

The label is a FixedLabel with a custom renderer.

I found out the crash only occurs if enabling TextSelection on a TextView:

Comment 3 Caan Mee 2016-01-26 16:36:10 UTC
Created attachment 14741 [details]
Sample project for crash on android
Comment 4 Caan Mee 2016-01-26 16:41:09 UTC
I found another case where this also happens:

I just added the feature to click on links in our app through the custom label:

Linkify.AddLinks(this.TextView, MatchOptions.All);
this.TextView.MovementMethod = LinkMovementMethod.Instance;

This causes the exact same crash as SetTextIsSelectable(true).
Comment 5 Chris Hardy [MSFT] 2017-06-19 16:18:18 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.