Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Longclick on Entry in ListView.Header crashes app

$
0
0

I found a bug in Xamarin.XForms for Android, which should be reproducable with the following code:

public class TestEntry: ContentPage {
    public TestEntry() {
        Content = new StackLayout { 
            Children = {
                new Entry {
                    Placeholder = "click long... ok!"
                },
                new ListView {
                    Header = new Entry {
                        Placeholder = "click long... app crashes!"
                    }                       
                }
            }
        };
    }
}

Long click on the second box and the app crashes on a real android device (on an emulator it just hangs without a logged error):

System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Forms.Platform.Android.CellAdapter.HandleContextMode (Android.Views.View view, Int32 position) [0x0005a] in <filename unknown>:0
  at Xamarin.Forms.Platform.Android.CellAdapter.OnItemLongClick (Android.Widget.AdapterView parent, Android.Views.View view, Int32 position, Int64 id) [0x00014] 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) [0x00019] in <filename unknown>:0
  at at (wrapper dynamic-method) System.Object:ae6769e0-9c27-4907-a5c4-7d5677ef27ed (intptr,intptr,intptr,intptr,int,long)

In my project I need to use Entries this way (inside a ListView.Header), our layout doesn't work as desired otherwise.
Fortunately the workaround from https://forums.xamarin.com/discussion/35704/listview-longpress-exception helps: setting Control.LongClickable = false in a custom EntryRenderer.
At least as long as we don't need the long click...


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>