Example usage for android.text BidiFormatter getInstance

List of usage examples for android.text BidiFormatter getInstance

Introduction

In this page you can find the example usage for android.text BidiFormatter getInstance.

Prototype

public static BidiFormatter getInstance(Locale locale) 

Source Link

Document

Factory for creating an instance of BidiFormatter given the context locale.

Usage

From source file:com.androidinspain.deskclock.timer.TimerSetupView.java

public TimerSetupView(Context context, AttributeSet attrs) {
    super(context, attrs);

    final BidiFormatter bf = BidiFormatter.getInstance(false /* rtlContext */);
    final String hoursLabel = bf.unicodeWrap(context.getString(R.string.hours_label));
    final String minutesLabel = bf.unicodeWrap(context.getString(R.string.minutes_label));
    final String secondsLabel = bf.unicodeWrap(context.getString(R.string.seconds_label));

    // Create a formatted template for "00h 00m 00s".
    mTimeTemplate = TextUtils.expandTemplate("^1^4 ^2^5 ^3^6", bf.unicodeWrap("^1"), bf.unicodeWrap("^2"),
            bf.unicodeWrap("^3"), FormattedTextUtils.formatText(hoursLabel, new RelativeSizeSpan(0.5f)),
            FormattedTextUtils.formatText(minutesLabel, new RelativeSizeSpan(0.5f)),
            FormattedTextUtils.formatText(secondsLabel, new RelativeSizeSpan(0.5f)));

    LayoutInflater.from(context).inflate(R.layout.timer_setup_container, this);
}