GithubHelp home page GithubHelp logo

tianhong1989 / autospannabletextview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wangshaolei/autospannabletextview

0.0 1.0 0.0 141 KB

Support some of the key words can be clicked with the underline TextView

Java 100.00%

autospannabletextview's Introduction

AutoSpannableTextView

Support some of the key words can be clicked with the underline TextView

Step1:

    <declare-styleable name="AutoLinkStyleTextView">
        <attr name="AutoLinkStyleTextView_text_value" format="string|reference"/>//key word with color and underline, and split with ','(en)
        <attr name="AutoLinkStyleTextView_default_color" format="color|reference"/>//word and underline's color
        <attr name="AutoLinkStyleTextView_has_under_line" format="boolean"/>//underline with true and false
        <attr name="AutoLinkStyleTextView_start_image" format="reference"/>//start with image 's TextView
        <attr name="AutoLinkStyleTextView_type">
            <enum name="start_image" value="0"/>
            <enum name="content_text" value="1"/>//default
        </attr>
    </declare-styleable>

Step2:

    //style1
    <xx.AutoLinkStyleTextView
        android:id="@+id/tv_clause"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="我已核对付款金额,仔细阅读并同意“购买须知”及约克论坛团购“用户条款”"
        android:textSize="16sp"
        app:AutoLinkStyleTextView_text_value="“购买须知”,“用户条款”"
        />
    //style2
    <xx.AutoLinkStyleTextView
        android:id="@+id/tv_start_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="活动介绍,开始以图片开头"
        android:textSize="16sp"
        app:AutoLinkStyleTextView_start_image="@mipmap/ic_qupai_subject_information"
        app:AutoLinkStyleTextView_type="start_image"
        />

Step3:

    //style1
    autoLinkStyleTextView.setOnClickCallBack(new AutoLinkStyleTextView.ClickCallBack() {
        @Override
        public void onClick(int position) {
            if (position == 0) {
                Toast.makeText(MainActivity.this, "购买须知", Toast.LENGTH_SHORT).show();
            } else if (position == 1) {
                Toast.makeText(MainActivity.this, "用户条款", Toast.LENGTH_SHORT).show();
            }
        }
     });
     
     //style2
     setStartImageText(tvStartImage.getText());

autospannabletextview's People

Watchers

tianhong1989 avatar

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.