首页 > 解决方案 > 单击 btn 调用快餐栏会导致崩溃

问题描述

首先,这是我第一次尝试 Xamarin(SDK 工具 26.1.1,SDK 平台工具 28.0,SDK 构建工具 27.0.0) 没有对示例代码进行任何修改,FloatingActionButton 成功显示 Snackbar。但是经过实验,我发现如果我在示例 TextView 中添加一个 ID,FAB 触发的 Snackbar 会导致崩溃。

为什么呢?我该如何克服呢?即包括没有崩溃的ID

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:id="@+id/textView1"
    android:text="Hello World!" />

感谢和 Rgds,参考

未处理的异常:

Android.Views.InflateException:发生

[appname] 已停止

再次打开应用

[add entire file as requested]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:id="@+id/textView1"
        android:text="Hello World!" />

</RelativeLayout>

标签: xamarin.android

解决方案


推荐阅读