Skip to content

Android TextView widget with more flexible span-link capabilities, include OnLinkClickListener and customed IntentSpan

Notifications You must be signed in to change notification settings

wtao901231/MinusLinkify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MinusLinkify

Android TextView widget with more flexible span-link capabilities, include OnLinkClickListener and customed IntentSpan.

Demo Screenshot

test onLinkClick and toast

Screenshot

test onInterruptSpanClick false, and open web default

Screenshot

test customed home intent

Screenshot

Xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.testapk.MainActivity" >

    <minus.android.view.LinkTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="www.google.com"
        android:autoLink="all" />

</RelativeLayout>

Code

LinkTextView v = new LinkTextView(this);
v.setAutoLinkMaskCompat(Linkify.ALL);
v.setText("www.google.com");

Listen onLinkClick

v.setOnLinkClickListener(new IOnLinkClickListener() {

	@Override
	public void onLinkClick(int type, String value) {
		Toast.makeText(MainActivity.this, value, Toast.LENGTH_SHORT).show();
	}
});

Decide whether onInterruptSpanClick or not

v.setOnInterruptSpanClickFilter(new IOnInterruptSpanClickFilter() {

	@Override
	public boolean onInterruptSpanClick(String scheme) {
		return false;
	}
});

Adavanced Usage

  • IntentSpan <a intent={-a android.intent.action.MAIN -c android.intent.category.HOME}>click and launch home</a>

format: <a intent={ADB-SHELL-AM-COMMAND}>LINK_TEXT</a>

  • ADB-SHELL-AM-COMMAND run adb shell, and using system am start to use, test and config link finally
  • LINK_TEXT visible to user, and response when on touch or click
  • LinkGestureDetector helper to implement YOUR LinkTextView

About

Android TextView widget with more flexible span-link capabilities, include OnLinkClickListener and customed IntentSpan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages