我有一个页面,我有一个REST API调用,并且在调试时它会成功地带来结果,但是我们得到一个未处理的异常,如果我们放一个try catch,没有显示细节,
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FCR.App.Views.DetailsContactNaPage">
<ContentPage.Content>
<Grid VerticalOptions="StartAndExpand" HorizontalOptions="CenterAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView x:Name="lstView" Grid.Row="0" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding NombreCompleto}" Detail="{Binding Descripcion}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Label Grid.Row="1" HorizontalOptions="Center" Text="¿Desea continuar registrando el contacto?" FontAttributes="Bold" FontSize="Medium" />
<Button Grid.Row="2" HorizontalOptions="Center" x:Name="dismissbutton" Text="Sí" Clicked="OnDismissButtonClicked"></Button>
<Button Grid.Row="3" HorizontalOptions="Center" x:Name="dismissbutton2" Text="No" Clicked="Clearnextview"></Button>
</Grid>
</ContentPage.Content>
</ContentPage>
然后是方法。
private async void Blurevent(object sender, FocusEventArgs e)
{
if (txtPnombre.Text != null && txtPapellido.Text != null)
{
var nombre = txtPnombre.Text.Trim();
var apellido = txtPapellido.Text.Trim();
var result = await App.NaturalezaManager.GetNombresApellidos(nombre,apellido);
if (result.Count >= 1)
{
var respuesta = await DisplayAlert("Registros", "Se han encontrado registros, ¿Desea verlos?", "Sí","No");
if (respuesta)
{
var detallepage = new DetailsContactNaPage(result);
await Navigation.PushModalAsync(detallepage);
//await DisplayAlert("Registrados", result[0].PrimerNombre + " "+ result[0].PrimerApellido+ "", "Sí", "No");
}
}
}
}
更新1:
错误
Xamarin引起的:android.runtime.JavaProxyThrowable: System.MissingMethodException:方法 &#39; Android.Widget.TextView.SetTextAppearance&#39;未找到。 Xamarin.Forms.Platform.Android.BaseCellView.BaseCellView(上下文 上下文,Cell cell):0 Xamarin.Forms.Platform.Android.TextCellRenderer.TextCellView.TextCellRenderer(上下文 上下文,Cell cell):0 Xamarin.Forms.Platform.Android.TextCellRenderer.GetCellCore(Cell item, 查看convertView,ViewGroup父级,上下文 上下文):0 Xamarin.Forms.Platform.Android.CellRenderer.GetCell(Cell item,View convertView,ViewGroup父级,Context 上下文):0 Xamarin.Forms.Platform.Android.CellFactory.GetCell(Cell item,View convertView,ViewGroup父级,上下文上下文,视图 视图):0 Xamarin.Forms.Platform.Android.ListViewAdapter.GetView(int position, 查看convertView,ViewGroup 亲本):0 Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_(IntPtr的 jnienv,IntPtr native__this,int position,IntPtr native_convertView, IntPtr native_parent):0 at(包装器 动态方法)System.Object:10d75808-73c9-4d3e-9e67-1b2609993ff0 (IntPtr的,IntPtr的,INT,IntPtr的,IntPtr的) md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.n_getView(母语 方法) md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.getView()ListViewAdapter.java:100 android.widget.HeaderViewListAdapter.getView()HeaderViewListAdapter.java:220 android.widget.AbsListView.obtainView()AbsListView.java:2346 android.widget.ListView.makeAndAddView()ListView.java:1876 android.widget.ListView.fillDown()ListView.java:702 android.widget.ListView.fillFromTop()ListView.java:763 android.widget.ListView.layoutChildren()ListView.java:1685 android.widget.AbsListView.onLayout()AbsListView.java:2148 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 android.support.v4.widget.SwipeRefreshLayout.onLayout()SwipeRefreshLayout.java:596 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewRenderer.n_onLayout(母语 方法) md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewRenderer.onLayout()ListViewRenderer.java:65 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout()FormsViewGroup.java:29 md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onLayout(母语 方法) md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onLayout()VisualElementRenderer_1.java:49 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout()FormsViewGroup.java:29 md5270abb39e60627f0f200893b490a1ade.Platform_ModalContainer.n_onLayout(母语 方法) md5270abb39e60627f0f200893b490a1ade.Platform_ModalContainer.onLayout()Platform_ModalContainer.java:53 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_onLayout(母语 方法) md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.onLayout()PlatformRenderer.java:63 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 android.widget.RelativeLayout.onLayout()RelativeLayout.java:1079 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 android.widget.FrameLayout.layoutChildren()FrameLayout.java:336 android.widget.FrameLayout.onLayout()FrameLayout.java:273 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 android.widget.LinearLayout.setChildFrame()LinearLayout.java:1735 android.widget.LinearLayout.layoutVertical()LinearLayout.java:1579 android.widget.LinearLayout.onLayout()LinearLayout.java:1488 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 android.widget.FrameLayout.layoutChildren()FrameLayout.java:336 android.widget.FrameLayout.onLayout()FrameLayout.java:273 com.android.internal.policy.PhoneWindow $ DecorView.onLayout()PhoneWindow.java:2934 android.view.View.layout()View.java:16639 android.view.ViewGroup.layout()ViewGroup.java:5437 android.view.ViewRootImpl.performLayout()ViewRootImpl.java:2179 android.view.ViewRootImpl.performTraversals()ViewRootImpl.java:1939 android.view.ViewRootImpl.doTraversal()ViewRootImpl.java:1115 android.view.ViewRootImpl $ TraversalRunnable.run()ViewRootImpl.java:6023 android.view.Choreographer $ CallbackRecord.run()Choreographer.java:858 android.view.Choreographer.doCallbacks()Choreographer.java:670 android.view.Choreographer.doFrame()Choreographer.java:606 android.view.Choreographer $ FrameDisplayEventReceiver.run()Choreographer.java:844 android.os.Handler.handleCallback()Handler.java:739 android.os.Handler.dispatchMessage()Handler.java:95 android.os.Looper.loop()Looper.java:148 android.app.ActivityThread.main()ActivityThread.java:5461 java.lang.reflect.Method.invoke(Native方法) com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run()ZygoteInit.java:726 com.android.internal.os.ZygoteInit.main()ZygoteInit.java:616