fill Prefix for float value in TextView - Android android.widget

Android examples for android.widget:TextView

Description

fill Prefix for float value in TextView

Demo Code

import android.text.TextUtils;
import android.widget.TextView;
import java.util.Calendar;

public class Main{

    public static void fillPrefix(TextView tv, float value, String prefix) {
        if (value == 0) {
            tv.setText("0.00" + prefix);
        } else if (value > 0) {
            if (!convertTextFloattoInt(String.valueOf(value))) {
                tv.setText(String.format("%.0f", value) + prefix);
            } else {
                tv.setText(String.format("%.2f", value) + prefix);
            }/*www  .ja  v a2 s  .c o  m*/
        } else {
            tv.setText("");
        }
    }

}

Related Tutorials