MonoDroid GetSpans last parameter

2019-06-21 19:38发布

问题:

I'm trying to use ISpannable in a Monodroid project but am having problems with GetSpans. What I'm ultimately after is a Rich Text editor such as at:

https://code.google.com/p/android-richtexteditor/source/browse/?r=4#svn/trunk/src/net/sgoliver

However, the Xamarin documentation for GetSpans isn't particularly helpful. The line I'm trying to convert from Java to C# is:

StyleSpan[] ss = s.getSpans(styleStart, position, StyleSpan.class);

However, I don't know what to pass for the last parameter as writing StyleSpan.class in C# gives a compile error of "} expected". What can I pass in to the last parameter to get all spans, or all spans of a particular type?

回答1:

The C# equivalent should be Java.Lang.Class.FromType(typeof(StyleSpan)).