https://github.com/zekunyan/linktextview
An Android TextView to add highly customizable and colorful link.
https://github.com/zekunyan/linktextview
android-textview java link
Last synced: 15 days ago
JSON representation
An Android TextView to add highly customizable and colorful link.
- Host: GitHub
- URL: https://github.com/zekunyan/linktextview
- Owner: zekunyan
- License: mit
- Created: 2014-10-28T12:36:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-17T16:15:03.000Z (over 10 years ago)
- Last Synced: 2025-04-03T09:05:20.685Z (about 2 months ago)
- Topics: android-textview, java, link
- Language: Java
- Homepage:
- Size: 462 KB
- Stars: 29
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LinkTextView
LinkTextView is an Android TextView to add highly customizable and colorful links.
## Features
* Easy to add link and attach data.
* Set link normal color and pressed color.
* Set background normal color and pressed color.## Sample
See the [LinkTextViewSample](https://github.com/zekunyan/LinkTextView/tree/master/LinkTextViewSample) for a common use of this library.
## How to use
Download the [LinkTextView.java](https://github.com/zekunyan/LinkTextView/blob/master/LinkTextView/LinkTextView.java) file and copy it into your project.
Add LinkTextView to your layout.
```xml```
Get the instance of LinkTextView.
```java
linkTextView = (LinkTextView) findViewById(R.id.linkTextView);
```Set text.
```java
linkTextView.setClickableText("Example link.");
```Add link with default color.
```java
int linkID = linkTextView.addClick(
linkBegin, //Link begin
linkEnd, //Link end
new LinkTextView.OnClickInLinkText() {
@Override
public void onLinkTextClick(String clickText, int linkID, Object attachment) {
Log.i(LOG_TAG, "You click manual link. It's attachment is: " + attachment);
}
},
"This is attachment." //Link attachment
);
```Or add link with custom color.
```java
int linkID = linkTextView.addClick(
linkBegin, //Link begin
linkEnd, //Link end
new LinkTextView.OnClickInLinkText() {
@Override
public void onLinkTextClick(String clickText, int linkID, Object attachment) {
Log.i(LOG_TAG, "You click example link. It's attachment is: " + attachment);
}
},
"This is example link attachment", //Link attachment
true, //Show link underline
Color.BLACK, //Text normal color
Color.YELLOW, //Text pressed color
Color.WHITE, //Background normal color
Color.GREEN //Background pressed color
);
```You can change specific Link's color by its ID.
```java
linkTextView.setTextPressedColor(linkID, Color.RED);
```You can remove specific link by its ID.
```java
linkTextView.removeLink(linkID);
```## Doc
[API Documentation](http://tutuge.me/LinkTextView/index.html).