Code example for NumberFormat

Methods: setMaximumFractionDigits, setMaximumIntegerDigits

0
    public volatile Location gpsLocation;
    public volatile float heading;
 
    public DrawOnTop(Context context) {
        super(context);
        nf.setMaximumIntegerDigits(3);
        nf.setMaximumFractionDigits(3);
//        star_on = BitmapFactory.decodeResource(getResources(), R.drawable.btn_star_big_on); 
//        star_off = BitmapFactory.decodeResource(getResources(), R.drawable.btn_star_big_off); 
    } 
 
    @Override 
    public void draw(Canvas canvas) {
        Paint paint = new Paint();
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(Color.BLACK);
        paint.setShadowLayer(2, 0, 0, Color.WHITE);
        paint.setTextSize(20);
        if (gpsLocation == null) {
            canvas.drawText("Loc: n/a", 24, 30, paint);
        } else {