# Android 开发实用小工具
来源:互联网 发布:淘宝商城运动女装 编辑:程序博客网 时间:2024/05/20 06:56
Case 1
// 格式化小数点后位数String tmp = String.format("tmp: ¥%.2f", 1f);System.out.println(tmp); ==> tmp: ¥1.00// 也可以这么用DecimalFormat df = new DecimalFormat("0.00");String tmp = df.format(1f);System.out.println(tmp); ==> 1.00
Case 2
// 数字前位补0String tmp = String.format("tmp: %04d", 2);System.out.println(tmp); ==> tmp: 0002// 也可以这么用DecimalFormat df = new DecimalFormat("0000");String tmp = df.format(2);System.out.println(tmp); ==> 0002
Case 3
// 判断字符串是否为null或空字符TextUtils.isEmpty(null) ==> trueTextUtils.isEmpty("") ==> true// 判断字符串是否是纯数字TextUtils.isDigitsOnly("1234") ==> trueTextUtils.isDigitsOnly("a123") ==> false
Case 4
View.java /** * 可以获取View在Screen上的坐标位置 * Computes the coordinates of this view on the screen. The argument * must be an array of two integers. After the method returns, the array * contains the x and y location in that order. * * @param location an array of two integers in which to hold the coordinates */public void getLocationOnScreen(int[] location)/** * 可以获取View在其所在Window内的坐标位置 * Computes the coordinates of this view in its window. The argument * must be an array of two integers. After the method returns, the array * contains the x and y location in that order. * * @param location an array of two integers in which to hold the coordinates */public void getLocationInWindow(int[] location)
Case 5
/** * 如果应用内有需要自己实现Activity的堆栈管理 * 不需要在每个Activity的生命周期内挨个方法添加事件了 * registerActivityLifecycleCallbacks已经帮您实现好啦。 */public class TestApplication extends Application { public void onCreate() { super.onCreate(); this.registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { @Override public void onActivityStopped(Activity activity) { // activity onStop } @Override public void onActivityStarted(Activity activity) { // activity onStart } @Override public void onActivitySaveInstanceState(Activity activity, Bundle outState) { // activity onSaveInstanceState } @Override public void onActivityResumed(Activity activity) { // activity onResume } @Override public void onActivityPaused(Activity activity) { // activity onPause } @Override public void onActivityDestroyed(Activity activity) { // activity onDestroy } @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { // activity onCreate } }); }}
Case 6
<Space/>
Case 7
<ViewStub/>
Case 8
<Merge>
Case 9
**android:animateLayoutChanges=”true”**LinearLayout中添加View的动画的办法,支持通过setLayoutTransition()自定义动画
Case 10
GradientDrawable渐变,可实现阴影效果<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape=["rectangle", "ring", "oval", "line"]> <corners android:radius="5dp" android:bottomLeftRadius="5dp" android:topLeftRadius="5dp" android:bottomRightRadius="5dp" android:topRightRadius="5dp"/> <stroke android:color="#00ffff" android:dashGap="3dp" android:dashWidth="10dp" android:width="1dp"/> <solid android:color="#ff00"/></shape>
Case 11
Android 开发你想要的工具,这里基本都全了。http://www.apkbus.com/thread-252748-1-1.html
0 0
- Android开发实用小工具
- Android开发实用小工具
- ANDROID开发实用小工具
- Android开发实用小工具
- # Android 开发实用小工具
- Android工具:Android开发实用小工具
- Android开发中的实用小工具
- wince开发实用小工具
- android 开发小工具
- Java Swing实用小工具开发
- Android实用小工具介绍之Monitor
- Android开发小工具总结
- 转载:Android 开发小工具
- Android开发之小工具
- 广师Android群分享之Android开发实用小工具,提升开发效率
- 分享Android开发实用小工具:图标批量提取工具:为APP开发快速获取资源
- 实用小工具
- 实用小工具集合
- Linux 服务器时间同步
- 第十四周 项目二二叉树排序树中查找的路径
- 第十周实践项目2 - 二叉树遍历的递归算法
- 基于 Web 的 Go 语言 IDE - Wide 1.5.2 发布!
- 时区转换样例
- # Android 开发实用小工具
- 第十六周项目1-算法验证
- 第33届 MPD软件工作坊(南京站)6大亮点抢先看!!!
- 《HTTP权威指南》学习笔记(二)—URL和资源
- 第十六周--归并排序
- 大数据系统处理技术总结
- 类自动载入
- 第十六周项目3—堆排序
- 微信网页授权