- 博客(33)
- 收藏
- 关注
转载 Android 按压状态改变背景色
Android 按压状态改变背景色<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/mine_item_bg_gray" android:state_pressed="true"/> <ite...
2017-07-06 13:13:00
414
转载 Retrofit+RxJava 简单介绍
Retrofit 是一个当前很流行的网络请求库 想使用它首先在gradle文件中引用 compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' compile ‘com.squareup.retrofit2...
2017-05-31 11:12:00
166
转载 Android 读取assets文件夹中json文件
这里要介绍一下读取assets文件夹中json文件 转换成list 集合只接看代码 非常简单public static List<State> getStates(Context context) { InputStream is = null; ByteArrayOutputStream bos = null; ...
2017-05-31 10:34:00
301
转载 Android 读取配置文件.properties
不啰嗦直接 上代码Properties properties = new Properties();try { InputStream in=context.getAssets().open("test.properties"); properties.load(in); in.close();...
2017-05-31 10:26:00
118
转载 Android studio项目依赖项冲突解决方法
1冲突Error:Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (25.1.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app...
2017-05-11 15:12:00
578
转载 Android 圆角View设置 圆角边框
圆角的Veiw XML<shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="@color/gray_white" /> 背景颜色 <corners android:radius="5dp" />...
2017-03-30 09:56:00
353
转载 Android 帧动画XML
帧动画 的XML<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@drawable/loading1" 动画图片 ...
2017-03-30 09:45:00
124
转载 选择图片(拍照,相册)及剪裁
写一个选择图片的utils //选择是否剪切图片构造函数 public CropPhotoUtils(ResultPhoto rp, Context context, boolean crop) { mRp = rp; mContext = context; isCrop = crop; takeF...
2017-03-24 17:34:00
127
转载 Android LogoActivity图片放大动画关闭
//logo淡入淡出动画 Drawable[] drawableArray = { getResources().getDrawable(R.drawable.logo_bg_begin), getResources().getDrawable(R.drawable.logo_bg_end) ...
2017-03-23 14:12:00
168
转载 Android EditText中输入价格判断
EditText 中输入价格判断mText.addTextChangedListener(new SimpleEditWatcher() { @Override public void afterTextChanged(Editable s) { final String text = s ==...
2017-02-23 17:38:00
266
转载 Android输入指定字符
输入0-9 . mEditText.setKeyListener(new NumberKeyListener() { @Override protected char[] getAcceptedChars() { char[] chars = {'0', '1', '2', '3', '4', ...
2017-02-23 17:35:00
176
转载 Android 日期Util
别人写好的Data 分享一下public static class Date { private static SimpleDateFormat m = new SimpleDateFormat("MM"); private static SimpleDateFormat d = new SimpleDateFormat("dd"); ...
2017-02-23 11:37:00
122
转载 Android判断网络状态
别人写好的分享一下 public static class NetWork { public static final String NETWORK_TYPE_WIFI = "wifi"; public static final String NETWORK_TYPE_3G = "eg"; public static fina...
2017-02-23 11:34:00
76
转载 Android dp与px
public static class Dimens { public static float dpToPx(Context context, float dp) { return dp * context.getResources().getDisplayMetrics().density; } ...
2017-02-23 11:08:00
92
转载 Android判断当前应用是否运行在后台
判断当前应用是否运行在后台public static boolean isApplicationInBackground(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ...
2017-02-23 11:01:00
263
转载 Android判断某个包名是否运行在顶层
判断某个包名是否运行在顶层public static Boolean isTopActivity(Context context, String packageName) { if (context == null || TextUtils.isEmpty(packageName)) { return null; } ActivityManager a...
2017-02-23 10:59:00
197
转载 Android判断是否是系统App
判断是否是系统Apppublic static boolean isSystemApplication(Context context, String packageName) { if (context == null) { return false; } Packa...
2017-02-23 10:54:00
805
转载 Android中安装App与卸载App
安装APP filePath 安装包的路径public static boolean installNormal(Context context, String filePath) { Intent i = new Intent(Intent.ACTION_VIEW); java.io.File file = new j...
2017-02-23 10:40:00
169
转载 Android 获取版本号,版本,Meta-Data
获取版本号public static int getVersionCode(Context context) { PackageManager pManager = context.getPackageManager(); PackageInfo packageInfo = null; try { ...
2017-02-23 10:36:00
289
转载 Android 从图库选择图片,拍照图片,裁剪图片
我直接写代码了1先来几个常亮private static final int PHOTO_REQUEST_CAREMA = 1;// 拍照private static final int PHOTO_REQUEST_GALLERY = 2;// 从相册中选择private static final int PHOTO_REQUEST_CUT = 3;// 结果private s...
2017-02-04 10:38:00
146
转载 Android 隐藏关闭软键盘
直接复制代码就可以用InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);if (imm != null) { imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowT...
2017-01-05 15:53:00
208
转载 Android EditText中插入话题模块的删除处理方法
在 EditText 中添加话题 或者是 @某人 时看起来挺简单,实际操作会有很多坑爹的问题private String mTopic;//光标保持在话题的末尾mInputEdit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ...
2016-12-08 15:09:00
378
转载 Android 6.0 权限请求
在申请权限之前一定要在清单配置文件中添加该权限private static final int MY_PERMISSIONS_REQUEST_RECORD_AUDIO = 1; //随便定义public void setPermission(){ if (ContextCompat.checkSelfPermission(this, Manifest.p...
2016-12-06 11:36:00
113
转载 Android 拖动View View跟随手指一动
/** * 拖动View 配合onTouchListener使用 * 设置View的布局属性,使得view随着手指移动 注意:view所在的布局必须使用RelativeLayout 而且不得设置居中等样式 * * @param view * @param rawY */private void moveViewWithFinger(View view, float rawY ,int...
2016-12-05 13:37:00
164
转载 Android 获取渠道名称
直接看代码,//获取渠道名称public static String getChannelName(Activity ctx) { if (ctx == null) { return null; } String channelName = ""; try { PackageManager packageManager = c...
2016-12-02 10:39:00
540
转载 Android 获取版本号
啥也不是,直接看代码public int getVersionCode(){ int versionCode = 0; try { PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(),0); versionCode = packageI...
2016-12-02 10:37:00
114
转载 EventBus使用
首先需要定义一个消息类,model。public class MessageEvent { private Object data; private String action; ......}在需要订阅事件的地方注册事件EventBus.getDefault().register(this);发送消息EventBus.getDefault().post(m...
2016-09-29 10:14:00
67
转载 Android Fragment替换View
在BaseActivity 中添加替换方法public void replace(int id, Fragment fragment) { getSupportFragmentManager() .beginTransaction() .replace(id, fragment) .commitAllowingS...
2016-09-29 10:01:00
523
转载 Java中货币格式化
private final static NumberFormat CURRENCY_FORMAT = NumberFormat.getCurrencyInstance(Locale.CHINA); //建立货币格式化引用public static String moneyCurrencyFormat(String money) { if (!TextUtils.isEmpty(m...
2016-09-28 09:50:00
400
转载 正则表达式判断字符串是否是手机号码
public static boolean isMobile(String mobiles) { Pattern p = Pattern.compile("^1(3|5|7|8|4)\\d{9}"); Matcher m = p.matcher(mobiles); return m.matches();}转载于:https://www.cnblogs.com/ted...
2016-09-27 15:30:00
651
转载 RecycleView可以策划的Item
public abstract class SwipeMenuViewHolder { /* 从左侧滑出菜单 */ public static final int EDGE_LEFT = 1; /* 从右侧滑出菜单 */ public static final int EDGE_RIGHT = 2; /* 默认从右侧滑出菜单 */ private in...
2016-09-27 11:43:00
100
转载 TextView,EditText中添加不同颜色的文字
在很多时候,在我们项目里需要用到在一个TextView中要显示不同颜色的文字private Spanned colorText(String text) { return Html.fromHtml(String.format("<font color='#ff989e'>%1$s</font>", text));}//设置文字textView.setT...
2016-09-26 11:26:00
351
转载 Android 网络请求库volley的封装,让请求更方便
首先封装一下volley 请求public class CustomRequest extends StringRequest { private static final String TAG = CustomRequest.class.getSimpleName(); private String mBody; private Map<String, S...
2016-09-23 14:03:00
137
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人