Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.wi

amitchaudhary.5913amitchaudhary.5913 amit chaudharyUSMember ✭✭

Getting error: Android.Views.InflateException: Binary XML file line #1: Error inflating class android.support.v7.widget.Toolbar

Main.axml

<?xml version="1.0" encoding="utf-8"?>





toolbar.axml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/actionBarSize"
android:background="?android:attr/colorPrimary"
android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar"/>

**MainActivity.cs
**

using System;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Xamarin.Forms;

namespace Thirsty
{
[Activity(Label = "Thirsty", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Android.Support.V7.App.AppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{

        base.OnCreate(bundle);
        SetContentView(Resource.Layout.Main);

        var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
        //SetActionBar(toolbar);


        toolbar.Title = "Hello Amit";
        SetSupportActionBar(toolbar);
        //ActionBar.Title = "Thirsty";




    }

/* public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.top_menus,menu);
return base.OnCreateOptionsMenu(menu);
}

    public override bool OnOptionsItemSelected(IMenuItem item)
    {
        Toast.MakeText(this, "Action Selected " + item.TitleFormatted, ToastLength.Short).Show();
        return base.OnOptionsItemSelected(item);
    }

*/

}

}

Problem: When I run on 5.0+, it runs fine but as soon as I execute it on 4.2, I get this error. Please help someone.

Best Answers

Answers

Sign In or Register to comment.