Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Resource.Id does not contain a definition

juliodanieljuliodaniel IDMember
edited July 2016 in Xamarin.Forms

hello guys .. i really dont understand about this problem ... i folowing the tutorial from Youtub about create Drawer Layout , but when i build it , i always got an error like this, i already folowing step by step the tutorial but maybe i have missed something that make my Solution Error.#ask
here is the code of the homepage
`using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using SupportToolbar = Android.Support.V7.Widget.Toolbar;
using Android.Support.V7.App;
using Android.Support.V4.Widget;
using System.Collections.Generic;
using Android.Content.Res;

namespace E_Library.Droid
{
[Activity(Label = "Login")]
public class HomePage : ActionBarActivity
{
private SupportToolbar mToolbar;
private MyActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
private ListView mLeftDrawer;
private ListView mRightDrawer;
private ArrayAdapter mLeftAdapter;
private ArrayAdapter mRightAdapter;
private List mLeftDataSet;
private List mRightDataSet;

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Create your application here
        SetContentView(Resource.Layout.HomePage1);

        mToolbar = FindViewById<SupportToolbar>(Resource.Id.toolbar);
        mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
        mLeftAdapter = FindViewById<ListView>(Resource.Id.left_drawer);
        mRightAdapter = FindViewById<ListView>(Resource.Id.right_drawer);

        mLeftDrawer.Tag = 0;
        mRightDrawer.Tag = 1;

        SetSupportActionBar(mToolbar);

        mLeftDataSet = new List<string>();
        mLeftDataSet.Add("Left Item1");
        mLeftDataSet.Add("Left Item2");
        mLeftAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
        mLeftDrawer.Adapter = mLeftAdapter;

        mRightDataSet = new List<string>();
        mRightDataSet.Add("Right Item 1");
        mRightDataSet.Add("Right Item 2");
        mRightAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, mRightDataSet);
        mRightDrawer.Adapter = mRightAdapter;

        mDrawerToggle = new MyActionBarDrawerToggle(
            this,               //Host Activity
            mDrawerLayout,      //Drawer Layout
            Resource.String.openDrawer, // Opened Messsage
            Resource.String.closeDrawer //Closed message
            );
        mDrawerLayout.SetDrawerListener(mDrawerToggle);
        SupportActionBar.SetHomeButtonEnabled(true);
        SupportActionBar.SetDisplayShowTitleEnabled(true);
        mDrawerToggle.SyncState();

        if (bundle != null)
        {
            if (bundle.GetString("DrawerState") == "Opened")
            {
                SupportActionBar.SetTitle(Resource.String.openDrawer);
            }

            else
            {
                SupportActionBar.SetTitle(Resource.String.closeDrawer);
            }
        }
        else
        {
            //This is the first the time the activity is ran
            SupportActionBar.SetTitle(Resource.String.closeDrawer);
        }
    }

    public override bool OnOptionsItemSelected(IMenuItem item)
    {
        switch(item.ItemId)
        {

            case Android.Resource.Id.Home:
            mDrawerLayout.CloseDrawer(mRightDrawer);
            mDrawerToggle.OnOptionsItemSelected(item);
             return true;

            case Resource.Id.action_refresh:
                //refresh
                return true;

            case Resource.Id.action_help:
                if(mDrawerLayout.IsDrawerOpen(mRightDrawer))
                {
                    //Righ Drawer is already open, close it
                    mDrawerLayout.CloseDrawer(mRightDrawer);
                }

                else
                {
                    //Right Drawer is closed, open it and just in case close left drawer
                    mDrawerLayout.OpenDrawer(mRightDrawer);
                    mDrawerLayout.CloseDrawer(mLeftDrawer);
                }

                return true;

            default:
                return base.OnOptionsItemSelected(item);
        }  
    }

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

    protected override void OnSaveInstanceState(Bundle outState)
    {
        if (mDrawerLayout.IsDrawerOpen((int)GravityFlags.Left))
        {
            outState.PutString("DrawerState", "Opened");
        }
        else
        {
            outState.PutString("DrawerState", "Closed");
        }
        base.OnSaveInstanceState(outState);
    }

    public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
    {
        base.OnConfigurationChanged(newConfig);
        mDrawerToggle.OnConfigurationChanged(newConfig);
    }
}

}`

and i always got an error like this :
Error CS0029 Cannot implicitly convert type 'Android.Widget.ListView' to 'Android.Widget.ArrayAdapter'
Error CS0029 Cannot implicitly convert type 'Android.Widget.ListView' to 'Android.Widget.ArrayAdapter'
Error CS0117 'Resource.Id' does not contain a definition for 'action_refresh' E_Library.Droid
Error CS0117 'Resource.Id' does not contain a definition for 'action_help' E_Library.Droid
Error CS0117 'Resource' does not contain a definition for 'Menu'

Sign In or Register to comment.