gpt4 book ai didi

xamarin.android - MonoDroid 如何在布局 axml 文件中使用自定义属性?

转载 作者:行者123 更新时间:2023-12-04 06:00:37 25 4
gpt4 key购买 nike

我正在尝试从这里转换 DragnDrop ListView https://github.com/commonsguy/cwac-touchlist到 C# 和 Mono for Android。

此自定义 View 的一部分需要使用一些自定义属性,这些属性在 Resources/values/attrs.xml 文件中声明如下:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="TouchListView">
<attr name="normal_height" format="dimension" />
<attr name="expanded_height" format="dimension" />
<attr name="grabber" format="reference" />
<attr name="dragndrop_background" format="color" />
<attr name="remove_mode">
<enum name="none" value="-1" />
<enum name="fling" value="0" />
<enum name="slide" value="1" />
<enum name="slideRight" value="1" />
<enum name="slideLeft" value="2" />
</attr>
</declare-styleable>
</resources>

然后我尝试在我的布局文件中使用它们,如下所示:
<app.monodroid.TouchListView xmlns:tlv="http://schemas.android.com/apk/res/app.monodroid"       
android:id="@+id/lstExercises"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/lExerciseActions"
android:drawSelectorOnTop="false"
tlv:normal_height="64dip"
tlv:grabber="@+id/icon"
tlv:remove_mode="slideRight"
/>

但是当我尝试构建我的项目时,我收到以下错误消息:

/Library/Frameworks/Mono.framework/External/xbuild/Novell/Novell.MonoDroid.Common.targets: Error: Tool exited with code: 1. Output: /Users/path_to_project/App.MonoDroid/obj/Debug/res/layout/add_session.axml:1: error: No resource identifier found for attribute 'normal_height' in package 'com.app.monodroid' /Users/path_to_project/App.MonoDroid/obj/Debug/res/layout/add_session.axml:1: error: No resource identifier found for attribute 'grabber' in package 'com.app.monodroid' /Users/path_to_project/App.MonoDroid/obj/Debug/res/layout/add_session.axml:1: error: No resource identifier found for attribute 'remove_mode' in package 'com.app.monodroid' (App.MonoDroid)



我的项目名称是 App.MonoDroid。

如何在布局文件中使用这些属性?

最佳答案

如果您为应用声明包名称,这些错误应该会消失。在项目属性中,转到 Android Manifest 选项卡,您将看到 Package Name 的文本字段:

Setting the package name

关于xamarin.android - MonoDroid 如何在布局 axml 文件中使用自定义属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8952470/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com