Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

rofiqsetiawan/Android-WordToSpan

Repository files navigation

Android-WordToSpan

Small & simple library to create a link url, mail, mention and tag in TextView. This is Xamarin.Android port of Bachors' Android-WordToSpan with little C#'s enhancement.

Screenshot

Nuget

PM> Install-Package Karamunting.Android.Bachors.AndroidWordToSpan -Version 1.0.0 

Usage

// Convert string to spannable & set text
const string myText = "I know http://just.com/anu how to @whisper, And I #know just #how to cry,I know just @where to anu@find.com the answers";
var tv = FindViewById<TextView>(R.Id.txt);
var wts = new WordToSpan();
// Set color link. Default = Color.Blue
wts.SetColorTag(Color.Green);
wts.SetColorUrl(Color.Magenta);
wts.SetColorMail(Color.Pink);
wts.SetColorMention(Color.Brown);
// Click listener with event handler.
// Call these before execute SetText()
wts.Click += (s, e) =>
{
#if DEBUG
 Log.Debug(nameof(MainActivity), "Triggered by Event Handler");
#endif
 Toast.MakeText(this, $"Type: {e.Type} | Text: {e.Text}", ToastLength.Short).Show();
};
wts.SetText(myText, tv);
```
You can also use Set
```csharp
// Click listener.
// Call these before execute SetText()
wts.SetClickListener(new ClickListener((type, text) =>
{
 Toast.MakeText(this, $"Type: {type} | Text: {text}", ToastLength.Short).Show();
}));
```
MIT
---

About

Small & simple library to create a link url, mail, mention and tag in TextView for Xamarin.Android.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /