20160312工作小计
来源:互联网 发布:linux 自启动文件 编辑:程序博客网 时间:2024/05/17 22:26
1:xutils访问网络出现retry error, curr request is null错误
原因:url没有加http前缀
2:listview隐藏滑动条 android:scrollbars="none"
listView隐藏item点击效果 android:listSelector="@android:color/transparent"
3:微信支付调起不了支付页面
a:签名文件有误
b:清除微信缓存
4:getAction()返回null 在清单文件中修改android:theme="@style/AppTheme"的上层style,改成
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
5:drawableTop,drawableLeft,drawableRight,drawableBottom设置图片和内容之间的距离使用drawablePadding设置
6:用xml画圆圈
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/color_e3a400" />
</shape>
设置控件的宽高一样即可
7:获取本地所有图片url的list列表
public static List<String> getMediaImage(Context context) {
List<String> list = new ArrayList<>();
final String orderBy = MediaStore.Images.Media.DATE_TAKEN;
final String[] columns = {MediaStore.Images.Media.DATA,
MediaStore.Images.Media._ID,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME};
Cursor imagecursor = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
null, orderBy + " DESC");
for (int i = 0; i < imagecursor.getCount(); i++) {
imagecursor.moveToPosition(i);
int dataColumnIndex = imagecursor
.getColumnIndex(MediaStore.Images.Media.DATA);
int dirColumnIndex = imagecursor
.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
String buckedName = imagecursor.getString(dirColumnIndex);
Log.v("image", "buckedName = " + buckedName);
String filename = imagecursor.getString(dataColumnIndex);
try {
File file = new File(filename);
if (!file.exists()) {
continue;
}
} catch (Exception e) {
continue;
}
list.add(imagecursor.getString(dataColumnIndex).toString());
}
imagecursor.close();
return list;
}
8:android studio打包apk,修改apk的版本号:在build.gradle中修改
9:onItemClick无响应:在item中修改checkbox,button的focusable=false
10:带checkbox的listview状态错乱问题:
a: 在设置checkbox(setChecked(true/false))状态时,if else必须成对出现
b:checkbox.setOnCheckListener必须放在checkbox.setChecked(true/false)之前
11:onSaveInstanceState保存值,onRestoreInstanceState取出值(适用于拍照等情况)
12:图片压缩
public static File getimage(String srcPath) {
BitmapFactory.Options newOpts = new BitmapFactory.Options();
newOpts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(srcPath, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
float hh = 800f;
float ww = 480f;
int be = 1;
if (w > h && w > ww) {
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be;
bitmap = BitmapFactory.decodeFile(srcPath, newOpts);
File file = new File(srcPath);
if (file.exists()) {
boolean flag = file.getAbsoluteFile().delete();
Log.i("TAG", "delete -->" + flag);
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return file;
}
原因:url没有加http前缀
2:listview隐藏滑动条 android:scrollbars="none"
listView隐藏item点击效果 android:listSelector="@android:color/transparent"
3:微信支付调起不了支付页面
a:签名文件有误
b:清除微信缓存
4:getAction()返回null 在清单文件中修改android:theme="@style/AppTheme"的上层style,改成
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
5:drawableTop,drawableLeft,drawableRight,drawableBottom设置图片和内容之间的距离使用drawablePadding设置
6:用xml画圆圈
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:useLevel="false">
<solid android:color="@color/color_e3a400" />
</shape>
设置控件的宽高一样即可
7:获取本地所有图片url的list列表
public static List<String> getMediaImage(Context context) {
List<String> list = new ArrayList<>();
final String orderBy = MediaStore.Images.Media.DATE_TAKEN;
final String[] columns = {MediaStore.Images.Media.DATA,
MediaStore.Images.Media._ID,
MediaStore.Images.Media.BUCKET_DISPLAY_NAME};
Cursor imagecursor = context.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
null, orderBy + " DESC");
for (int i = 0; i < imagecursor.getCount(); i++) {
imagecursor.moveToPosition(i);
int dataColumnIndex = imagecursor
.getColumnIndex(MediaStore.Images.Media.DATA);
int dirColumnIndex = imagecursor
.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
String buckedName = imagecursor.getString(dirColumnIndex);
Log.v("image", "buckedName = " + buckedName);
String filename = imagecursor.getString(dataColumnIndex);
try {
File file = new File(filename);
if (!file.exists()) {
continue;
}
} catch (Exception e) {
continue;
}
list.add(imagecursor.getString(dataColumnIndex).toString());
}
imagecursor.close();
return list;
}
8:android studio打包apk,修改apk的版本号:在build.gradle中修改
9:onItemClick无响应:在item中修改checkbox,button的focusable=false
10:带checkbox的listview状态错乱问题:
a: 在设置checkbox(setChecked(true/false))状态时,if else必须成对出现
b:checkbox.setOnCheckListener必须放在checkbox.setChecked(true/false)之前
11:onSaveInstanceState保存值,onRestoreInstanceState取出值(适用于拍照等情况)
12:图片压缩
public static File getimage(String srcPath) {
BitmapFactory.Options newOpts = new BitmapFactory.Options();
newOpts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(srcPath, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
float hh = 800f;
float ww = 480f;
int be = 1;
if (w > h && w > ww) {
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) {
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be;
bitmap = BitmapFactory.decodeFile(srcPath, newOpts);
File file = new File(srcPath);
if (file.exists()) {
boolean flag = file.getAbsoluteFile().delete();
Log.i("TAG", "delete -->" + flag);
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
fileOutputStream.flush();
fileOutputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return file;
}
0 0
- 20160312工作小计
- 工作小计
- shell 命令小计——工作笔记
- 小计
- 小计
- oracle小计
- 学习小计
- ISPCP 小计
- SMARTFORMS 小计
- MM小计
- html小计
- ABAP小计
- 树小计
- 随笔小计
- typedef小计
- 小计 合计
- 接口小计~~~~
- EditText小计
- JavaScript练习(二)
- 笔记(c)
- 两位数的大数乘法
- 一步一步实现一个简单的OS(试验任务切换)
- 工业相机IDS开发
- 20160312工作小计
- IOS Xcode7.1新建纯代码工程
- 编程技巧笔记
- 大学毕业4年-回顾和总结(3)-投资理财观-图穷而真相现
- 【leetcode】Array——Jump Game(55)
- 翻译 Cg Program in Unity - 2.4 Silhouetten Enhancement
- tslib 1.4 在ARM板上移植(转)
- code forces 548C:Mike and frog
- leetcode 做题记录3