持續(xù)更新...
用于進(jìn)行dip和px轉(zhuǎn)換:
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
用于進(jìn)行px和dip轉(zhuǎn)換
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
檢測一段文字中是否含有某個詞匯
public static boolean isHaveWord(String original,String haveWord){
boolean flag=false;
String replaceStr=original;
if ((replaceStr.replaceAll(haveWord,"")).length()!=original.length()){
flag=true;
}
return flag;
}