Created
February 17, 2015 15:38
-
-
Save patridge/2ca7e309cd53716fb384 to your computer and use it in GitHub Desktop.
Android: what ID is that thing?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I had to use this to debug why `OnOptionsItemSelected` wasn't triggering for an ActionBar home tap. | |
// Turns out, `Resource.Id.home` and `Resource.Id.homeAsUp` are not related to `Android.Resource.Id.Home`. | |
var projectIdType = typeof(Resource.Id); | |
foreach (var field in projectIdType.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) { | |
if (item.ItemId == (int)field.GetValue(null)) { | |
Console.WriteLine("{0}: {1}", field.Name, item.ItemId); | |
} | |
} | |
var androidIdType = typeof(Android.Resource.Id); | |
foreach (var field in androidIdType.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) { | |
if (item.ItemId == (int)field.GetValue(null)) { | |
Console.WriteLine("{0}: {1}", field.Name, item.ItemId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment