Skip to content

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

License

Notifications You must be signed in to change notification settings

rofiqsetiawan/Android-WordToSpan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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