【发布时间】:2017-03-09 08:49:19
【问题描述】:
我是 Xamarin 的新手。我从 Nuget 包管理器安装了 Android.Support.V7.App 库,并且项目构建成功。现在,当我扩展 AppCompatActivity 而不是 Activity 时,我得到了异常:-
Android.Content.Res.Resources+NotFoundException: Resource ID #0x7f030015
我的活动代码如下:-
using Android.App;
using Android.Widget;
using Android.OS;
using Android.Content;
using Android.Preferences;
using Android.Support.V7.App;
namespace ExampleDemo
{
[Activity(Label = "ExampleDemo", Icon = "@drawable/icon")]
public class MainActivity : AppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main);
}
}
}
我的 axml 文件包含此代码:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/MyButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/Hello"
android:layout_marginTop="50dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp" />
</LinearLayout>
谁能告诉我我做错了什么??
提前致谢。
【问题讨论】:
-
异常发生在哪里? (当您滚动调试输出时,您应该会找到更多信息)
-
清洁解决方案适用于我的 MainActivity。但是当我使用
时,它给了我另一个异常:- Android.Views.InflateException:二进制 XML 文件第 1 行:二进制 XML 文件第 1 行:膨胀类 android.support 时出错。 design.widget.TextInputLayout @Malte
标签: c# xamarin visual-studio-2015 xamarin.android