Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top