public static String formatStringUpto2DigitDecimal(String orig) { String newValue = orig.substring(orig.indexOf(".")); if(newValue.length() > 3){ System.out.println("newValue : " + newValue + " New : " + newValue.substring(0,3)); return orig.substring(0,orig.indexOf(".")).concat(newValue.substring(0,3)); } return orig; }
Android Learning
Sunday, May 28, 2017
Format String value up to 2 decimal place in Java
Wednesday, May 17, 2017
Change the Background Color on Run-time/Pragmatically of Shape Draw-able in Android.
How to Change the Background Color on Run-time/Pragmatically of Shape Draw-able in Android.
GradientDrawable gradientDrawable = (GradientDrawable) myView.getBackground();//To change the solid color
gradientDrawable .setColor(yourColor)
//To change the stroke color
int width_px = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics());
gradientDrawable .setStroke(width_px, Color.Black);
Subscribe to:
Posts (Atom)