Search code examples
c#androiddot42

How to access android.R.id.home with Dot 42


I am trying to translate the following into C# with Dot 42

@Override public boolean onOptionsItemSelected(MenuItem item) 
{ 
    switch (item.getItemId()) 
{ 
       case android.R.id.home: 
            return(true);
       case R.id.about: 
            return(true);
       case R.id.help: 
            return(true);
}
return(super.onOptionsItemSelected(item));
}

My main problem right now is the android.id.home The Intellisense does not show a Home member of Android.R.Id What am I missing here? BTW if you would like to translate the full block into C#, thanks, but I'm pretty sure the rest of it will not pose much a problem.


Solution

  • public override bool OnOptionsItemSelected(Android.View.IMenuItem item)
    {
        switch (item.GetItemId())
        {
            case Android.R.Id.Home: // API level 11 and higher (Android 3.0) 
                return (true);
            case R.Id.About:
                return (true);
            case R.Id.Help:
                return (true);
        }
        return (base.OnOptionsItemSelected(item));
    }
    

    Note that R.Id.Home identifies a resource in the platform, hence the Android scope.

    enter image description here

    Assumably, About and Help are application resource identifiers.