常用工具類

2021-07-08 22:24:11 字數 4525 閱讀 6980

本講內容:常用工具類(陸續更新)

/**

* @author administrator

* */

public static context context;

public void oncreate()

public static context getcontext()

}

2、提供所有activity呼叫

/**

* 基類

* @author administrator

* */

public class baseactivity extends activity

/*** 列印toast

* * @param msg

*/toast mtoast;

public void showtoast(final string text) else

mtoast.show();

}});

} }public void showtoast(final int resid) else

mtoast.show();

}});

} /**

* 列印log

* * @param msg

*/public void showlog(string msg)

/*** 跳轉activity

* * @param cla

*/public void startanimactivity(class<?> cla)

public void startanimactivity(intent intent)

}

3、畫素轉換工具

/**

* 畫素轉換工具

*/public class pixelutil

/*** dp轉 px.

*/public static int dp2px(float value, context context)

/*** px轉dp.

*/public static int px2dp(float value)

/*** px轉dp.

*/public static int px2dp(float value, context context)

/*** sp轉px.

*/public static int sp2px(float value) else

float spvalue = value * r.getdisplaymetrics().scaleddensity;

return (int) (spvalue + 0.5f);

} /**

* sp轉px.

*/public static int sp2px(float value, context context) else

float spvalue = value * r.getdisplaymetrics().scaleddensity;

return (int) (spvalue + 0.5f);

} /**

* px轉sp.

*/public static int px2sp(float value)

/*** px轉sp.

*/public static int px2sp(float value, context context)

}

4、手機公共屬性

public class commonutils 

return false;

} /** 檢查是否是wifi */

public static boolean iswifi(context context)

return false;

} /** 檢查是否是流動網路 */

public static boolean ismobile(context context)

return false;

} private static networkinfo getnetworkinfo(context context)

/** 檢查sd卡是否存在 */

public static boolean checksdcard()

}

5、顏色

<?xml version="1.0" encoding="utf-8"?>

#ffffff

#fffff0

#ffffe0

#ffff00

#fffafa

#fffaf0

#fffacd

#fff8dc

#fff5ee

#fff0f5

#ffefd5

#ffebcd

#ffe4e1

#717171

#ffe4c4

#ffe4b5

#ffdead

#ffdab9

#ffd700

#ffc0cb

#ffb6c1

#ffa500

#ffa07a

#ff8c00

#ff7f50

#ff69b4

#ff6347

#ff4500

#ff1493

#ff00ff

#ff00ff

#ff0000

#fdf5e6

#fafad2

#faf0e6

#faebd7

#fa8072

#f8f8ff

#f5fffa

#f5f5f5

#f5f5dc

#f5deb3

#f4a460

#f0ffff

#f0fff0

#f0f8ff

#f0e68c

#f08080

#eee8aa

#ee82ee

#e9967a

#e6e6fa

#e0ffff

#deb887

#dda0dd

#dcdcdc

#dc143c

#db7093

#daa520

#da70d6

#d8bfd8

#d3d3d3

#d3d3d3

#d2b48c

#d2691e

#cd853f

#cd5c5c

#c71585

#c0c0c0

#bdb76b

#bc8f8f

#ba55d3

#b8860b

#b22222

#b0e0e6

#b0c4de

#afeeee

#adff2f

#add8e6

#a9a9a9

#a9a9a9

#a52a2a

#a0522d

#9932cc

#98fb98

#9400d3

#9370db

#90ee90

#8fbc8f

#8b4513

#8b008b

#8b0000

#8a2be2

#87cefa

#87ceeb

#808080

#808080

#808000

#800080

#800000

#7fffd4

#7fff00

#7cfc00

#7b68ee

#778899

#778899

#708090

#708090

#6b8e23

#6a5acd

#696969

#696969

#66cdaa

#6495ed

#5f9ea0

#556b2f

#4b0082

#48d1cc

#483d8b

#4682b4

#4169e1

#40e0d0

#3cb371

#32cd32

#2f4f4f

#2f4f4f

#2e8b57

#228b22

#20b2aa

#1e90ff

#191970

#00ffff

#00ffff

#00ff7f

#00ff00

#00fa9a

#00ced1

#00bfff

#008b8b

#008080

#008000

#006400

#0000ff

#0000cd

#00008b

#000080

#000000

#00000000

常用工具類

reflectionutils objectutils public static void main string args 判斷兩個陣列是否相等 system.out.println arrays.equals arr,arr true 列印陣列 string s1 arrays.tostrin...

常用工具類 作業

1.生成10個 10,23 之間的隨機整數 random 類的nextdouble 或nextint 實現public class randomdemo for int i 1 i 10 i 1.以樹狀結構輸出計算機某個指定資料夾下的所有的檔案和子資料夾名稱。public class filedem...

Android Studio常用工具類

今天給大家介紹幾個studio中常用到的工具類 簡單明瞭 第乙個butterknife 首先介紹一些它,butterknife 是乙個註解框架,可以代替 findviewbyid butter knife優勢 在使用中需要注意的事項 1.activity butterknife.bind this ...