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;
    }
0 0