Giter VIP home page Giter VIP logo

linktextview's Introduction

LinkTextView

QMUI是个好库但是配置麻烦,但是为了使用其中一个功能而依赖整个项目不值得.
所以单独抽出了QMUI中的LinkTextView,支持点击文本中的电话号,邮箱,链接
因为功能单一所以短期内应该都不会再更新了,我也只是把源码扣出来用,去掉了其他没用的代码而已
共有10个java类和5个接口类

效果图

依赖

implementation 'com.alex:textView:1.0.0'

使用

xml中

<com.alex.textview.view.LinkTextView
       android:id="@+id/text"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_centerInParent="true"
       android:text="可以自动识别网页链接,例如 http://www.qmuiteam.com。\n可以自动识别电话号码,例如 13600000000。\n也可以识别邮件地址,例如 [email protected]。\n我们可以为其添加自定义的点击事件。" />

Activity中

LinkTextView textView = findViewById(R.id.text);
textView.setOnLinkClickListener(new LinkTextView.OnLinkClickListener() {
   @Override
   public void onTelLinkClick(String phoneNumber) {
       Toast.makeText(MainActivity.this, "识别到电话号码是:" + phoneNumber, Toast.LENGTH_SHORT).show();
   }

   @Override
   public void onMailLinkClick(String mailAddress) {
       Toast.makeText(MainActivity.this, "识别到邮件地址是:" + mailAddress, Toast.LENGTH_SHORT).show();
   }

   @Override
   public void onWebUrlLinkClick(String url) {
       Toast.makeText(MainActivity.this, "识别到网页链接是:" + url, Toast.LENGTH_SHORT).show();
   }
});

linktextview's People

Contributors

alexfugui avatar

Stargazers

一个努力成为大牛程序猿 avatar Rexzzz avatar  avatar 果丹皮 avatar  avatar Nuyoah avatar  avatar Zachery avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

yufeilong92

linktextview's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.