Android Resource.Layout.filename返回错误的布局文件
我有一个Android Resource.Layout.filename返回错误的布局文件,android,visual-studio-2010,xamarin.android,Android,Visual Studio 2010,Xamarin.android,我有一个MonoDroid应用程序项目(我们称之为mainApp)。这引用了app.Screenproject,它是一个MFA库项目。最初,我的活动是在mainApp项目中进行的。一切正常。我需要在app.Screen项目中放置一些活动(以及资源、绘图等)。 我已将所需的所有资源移动到app.Screen项目。它构建得很好,在我的活动(位于app.screens中)中,我可以访问Resource.Layout.filename,甚至Layout.Id.name 但是,当我运行应用程序时,在Set
MonoDroid
应用程序项目(我们称之为mainApp
)。这引用了app.Screen
project,它是一个MFA库项目。最初,我的活动是在mainApp
项目中进行的。一切正常。我需要在app.Screen
项目中放置一些活动(以及资源、绘图等)。
我已将所需的所有资源移动到app.Screen
项目。它构建得很好,在我的活动(位于app.screens中)中,我可以访问Resource.Layout.filename
,甚至Layout.Id.name
但是,当我运行应用程序时,在SetContentView(Resource.Layout.filename)
中,我得到了错误的布局文件。这显然会导致FindById()
返回null
,因为它在此布局文件中没有这些按钮
我发现同一布局文件在我的MFA库项目中的Id与mainApp项目中的Id不同,如下所示:
// In the mainApp project
public partial class Layout
{
// aapt resource value: 0x7f030001
public const int DeliveryScreenLayout = 2130903041;
// aapt resource value: 0x7f03000a
public const int splash_screen_layout = 2130903050;
private Layout()
{
}
}
// in app.screen library project
public partial class Layout
{
// aapt resource value: 0x7f030000
public static int has_hello_layout = 2130903040;
// aapt resource value: 0x7f030001
public static int splash_screen_layout = 2130903041;
private Layout()
{
}
}
我正在使用VS2010和MFA4.0,我的项目是针对Android 4.0的。我尝试了Clean&Build
,删除了/Bin
和/Obj
文件夹,但没有成功。
任何帮助都将不胜感激 这似乎是
MonoDroid
中的一个bug,下面是Xamarin bugzilla中的
这是由于MFA库项目中的Resource.Designer.cs
与主项目在其Resource.Designer.cs
文件中的ID(int)值不同而造成的
我已经想出了一个解决办法。在我的mainApp
中,我手动调用mainApp.Resources.UpdateIdValues()这将更新其他MFA库项目中的资源
id值
Xamarin说这个错误在4.6.4中得到了解决。但是我还没有测试这个补丁