xamarin.android - 单击 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,参考
- VS上的对话框:
未处理的异常:
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>
解决方案
推荐阅读
- ide - WebStorm 中的语法高亮
- go - 如何从 Visual Studio Code 中的包覆盖范围中排除生成的模拟
- javascript - 遍历 JavaScript 中每个列表项的数组
- css - CSS网格中的Flexbox:如何定位弹性项目
- c# - 如何在 WPF DataGrid 中获取 SelectedCells 的“锚”单元格?
- jquery - jQuery 追加/前置在 Edge 中不起作用?
- javascript - forEach 回调中第三个参数(数组)的用途是什么?
- react-native - HTML 块元素的等效行为
- javascript - 5个随机数,第一个数字不为零
- ag-grid - ag-grid Grid 在 iPad Air os 10.1.1 上不可见