Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

android string animation

public class Typewriter extends TextView {

    private CharSequence mText;
    private int mIndex;
    private long mDelay = 500; //Default 500ms delay


    public Typewriter(Context context) {
        super(context);
    }

    public Typewriter(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    private Handler mHandler = new Handler();
    private Runnable characterAdder = new Runnable() {
        @Override
        public void run() {
            setText(mText.subSequence(0, mIndex++));
            if(mIndex <= mText.length()) {
                mHandler.postDelayed(characterAdder, mDelay);
            }
        }
    };

    public void animateText(CharSequence text) {
        mText = text;
        mIndex = 0;

        setText("");
        mHandler.removeCallbacks(characterAdder);
        mHandler.postDelayed(characterAdder, mDelay);
    }

    public void setCharacterDelay(long millis) {
        mDelay = millis;
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: power of a number in java 
Java :: Which of the below is a correct identifier for a method name in Java * 2 points 0start #stop 0_start *start# 
Java :: java mcq test 
Java :: how to hide search from menu android studio from activity 
Java :: prime numbers most efficient algorithm java 
Java :: textfield invisible java 
Java :: longest subarray with equal 0 and 1 
Java :: java %2C 
Java :: Picked up _JAVA_OPTIONS: -Xmx256M intillij 
Java :: Java TestNG Data Provider 
Java :: Show the difference between this() and super() with help of a code 
Java :: Algorithms - filtering 
Java :: leap year java method 
Java :: how to cut a certion part from a string in java 
Java :: number guessing game in java using oops 
Java :: os compatible java path separator 
Java :: validate text field netbeans emails 
Java :: spinner android add underline like edittext 
Java :: extended window style values in java 
Java :: convert python to java translator online 
Java :: sort array from certain index java 
Java :: Java Shuffling Using shuffle() 
Java :: how to decode a ByteArray to Bitman in adroid 
Java :: java.lang.stackoverflowerror null onetomany 
Java :: spring generate banner 
Java :: default access modifier java 
Java :: asserttrue in selenium java 
Java :: how to create database in java 
Java :: retrofit gradle 
Java :: how to check if rs next is null 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =