Android 工具类
无の常
Android python 人工智能
展开
-
Android 工具类(将 dp 转成 px 获取屏幕的高度/宽度 判断android SDK 版本是否大于等于5.0)
public class Utils { private static int screenWidth = 0; private static int screenHeight = 0; /** * 将 dp 转成 px * @param dp * @return */ public static int dpToPx(int dp) { return (int) (dp * Resources.原创 2015-06-19 16:35:38 · 2299 阅读 · 0 评论 -
获取屏幕尺寸大小
DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); // 屏幕宽 int widthPixels = dm.widthPixels; // 屏幕高 int heightPixels = dm.hei原创 2015-07-22 18:19:35 · 371 阅读 · 0 评论 -
将InputStream(输入流)转成String 的方法
public static String readInputStream(FileInputStream inStream) { try { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int le原创 2015-08-03 23:33:25 · 453 阅读 · 0 评论 -
单例模式(懒汉式和饿汉式)
public class Singleton { private volatile static Singleton mSingleton; private Singleton() {} public static Singleton getInstance() { if (mSingleton == null) {原创 2015-07-23 20:35:10 · 224 阅读 · 0 评论