摘要:
官方文档:http://www.gradle.org/docs/current/userguide/build_environment.html以下配置写在gradle.properties中://以下为http协议proxy配置systemProp.http.proxyHost=www.someh... 阅读全文
随笔分类 - 关于Android
ListView隐藏HeadView
2014-07-27 15:24 by 默契., 389 阅读, 收藏,
摘要:
把HeadView及其子View的Visibility都设置成GONE就行了,只设置HeadView的Visibility不行;private void setHeadViewVisibility(int visibility){ headlineView.setVisibility(visi... 阅读全文
Android获取基站信息
2013-12-31 16:31 by 默契., 1333 阅读, 收藏,
摘要:
package cn.police.bz.util;import android.content.Context;import android.telephony.CellLocation;import android.telephony.TelephonyManager;import android.telephony.cdma.CdmaCellLocation;import android.telephony.gsm.GsmCellLocation;public class BaseStationInfoHelper { public static class BaseStation... 阅读全文
Android获取签名相同的软件列表(签名比对)
2013-12-30 16:10 by 默契., 446 阅读, 收藏,
摘要:
try { PackageManager pmg = getPackageManager(); List apps = pmg.getInstalledApplications(0); Signature ss1 = pmg.getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES).signatures[0]; for (int i = 0; i < apps.size(); i++) { S... 阅读全文
HttpClient两个超时设置的区别
2013-12-19 14:53 by 默契., 414 阅读, 收藏,
摘要:
HttpClient关于超时有两个设置,一个是CONNECTION_TIMEOUT还有一个是SO_TIMEOUT;CONNECTION_TIMEOUT是指的是,从发出TCP请求,到建立起连接的时间,一般比较小,如:5*1000SO_TIMEOUT是指从建立起连接到结束的时间,一般比较大,如:30*1000;这两个值默认好像都是无限大,在使用中务必进行设置,否则可能造成软件卡死,当多个线程使用同一个HttpClient的时候,如果一个线程没有执行完成,另外一个线程也是无法执行的; 阅读全文
HttpClient的文件上传进度
2013-12-19 10:03 by 默契., 1424 阅读, 收藏,
摘要:
package cn.police.bz.util;import java.io.File;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import org.apache.http.entity.mime.content.FileBody;import android.util.Log;/** * 能够显示进度的FileBody * * @author Mr_wu */public class FileBodySomeProgress extends FileBody { . 阅读全文
Animation中缩放View,中断动画后在低版本手机上背景无法还原的问题;
2013-11-28 10:01 by 默契., 431 阅读, 收藏,
摘要:
Animation代码如下import android.view.animation.Animation;import android.view.animation.Transformation;public class MetroAnimation extends Animation { private int width; private int height; public MetroAnimation(int width, int height) { this.width = width / 2; this.height = height ... 阅读全文
Android让Diglog中的元素fill_parent属性生效
2013-11-18 09:02 by 默契., 265 阅读, 收藏,
摘要:
lodingDialog = new Dialog(this,R.style.dialog_noBorder); lodingDialog.setContentView(R.layout.file_explore_dialog_loading); //让ContentView的fill_parent属性生效 lodingDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); 阅读全文
Android用java代码转换dp或者sp到px
2013-11-15 16:09 by 默契., 1246 阅读, 收藏,
摘要:
/** * dp转px * * @param res * android.content.res.Resources * @param dp * @return */ public static int dpToPx(Resources res, int dp) { return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.getDisplayMetrics()); } /** * ... 阅读全文
获取ScrollView的可见高度,和获取HorizontalScrollView的可见宽度
2013-11-15 15:50 by 默契., 1499 阅读, 收藏,
摘要:
final ScrollView scrollView=(ScrollView)findViewById(R.id.scrollView);final HorizontalScrollView horizontalScrollView=(HorizontalScrollView)findViewById(R.id.horizontalScrollView);//获取控件可见高度final int scrollViewHeight=scrollView.getMeasuredHeight();//获取控件可见宽度final int horizontalScrollViewWidth=horizo 阅读全文
关于自定义ViewGroup在ScrollView中无法显示的问题.
2013-11-04 16:04 by 默契., 419 阅读, 收藏,
摘要:
你需要在自定义ViewGroup中重写onMeasure方法,用来计算ViewGroup所需要的宽度和高度,然后setMeasuredDimension(width,height);protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { //省略计算过程 setMeasuredDimension(720, 2000); } 然后你就惊奇的发现可以了,,,,,我靠!!!! 阅读全文
Android源码混淆脚本proguard
2013-10-24 11:32 by 默契., 418 阅读, 收藏,
摘要:
怎么用?1,工程根目录下创建一个文件proguard.cfg;(名字随便起)2,在project.properties末尾添加一行proguard.config=proguard.cfg怎么写?先来个现成的:#优化级别-optimizationpasses 5-dontusemixedcaseclassnames-dontskipnonpubliclibraryclasses#不预审核-dontpreverify#屏蔽警告信息-ignorewarnings -verbose-optimizations !code/simplification/arithmetic,!field/*,!clas 阅读全文
关于Bitmap内存溢出问题
2013-10-23 16:51 by 默契., 1475 阅读, 收藏,
摘要:
在做一个新闻客户端列表的时候遇到了这个问题,加载50条数据左右就内存溢出了.打印看了下100kb的图片变成Bitmap大概有1MB,可想而知这个内存消耗有好大;谷歌搜索解决方案,大概方向:1,压缩Bitmap2,使用软引用(不知道怎么用)3,使用磁盘缓存最后我选择了使用磁盘缓存,,,,,,,但是,,尼玛什么时候释放内存进行缓存呢???试了几种释放内存的时机,都没有很好的结果,,,最后,找到了一个开源框架,一个只需要导入jar包(没有资源文件所以可以只用导入jar包)的Android框架,太爽了,太好用了!!!两句代码解决问题(其中一句只用执行一次)有木有,什么后台图片下载,什么子线程修改UI, 阅读全文
WebView退出时停止视频播放
2013-10-23 12:10 by 默契., 1607 阅读, 收藏,
摘要:
网上比较流行的方法:在activity的onPause函数中调用webview的onPause函数。弊端:视频虽然停止播放但是还是在从网上加载数据(观察流量统计);比较好的方法:在activity的onPause函数中调用webview的onPause函数。在activity的onDestroy函数中webview.loadUrl("file:///android_asset/nonexistent.html");原文:http://stackoverflow.com/questions/5946698/how-to-stop-youtube-video-playing-i 阅读全文
WebView页面加载完成后报空指针异常
2013-10-23 09:45 by 默契., 578 阅读, 收藏,
摘要:
在手机上运行的好好的,模拟器上死活不行;异常内容如下:java.lang.NullPointerExceptionat android.webkit.WebViewDatabase.getCacheTotalSize(WebViewDatabase.java:734)at android.webkit.CacheManager.trimCacheIfNeeded(CacheManager.java:548) at android.webkit.WebViewWorker.handleMessage(WebViewWorker.java:190)at android.os.Handler.dis 阅读全文
最近一次Android源码编译过程
2013-10-21 13:44 by 默契., 1573 阅读, 收藏,
摘要:
系统:ubuntu12.04 32位!!!!注意:1,不要使用64位ubuntu2,务必分配4g或者以上的swap空间一,源码下载谷歌搜索download android source code,第一个结果就是官方文档(http://source.android.com/source/downloading.html)教你怎么下载源码,大概步骤如下:1,在当前用户的home目录下创建一个文件夹来保存一写可执行文件,并把该文件夹加到环境变量中;mkdir ~/binPATH=~/bin:$PATH2,安装curl,安装git,下载Repo;sudoapt-getinstallcurlsudoap 阅读全文
警告:Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the ...
2013-10-18 08:06 by 默契., 2792 阅读, 收藏,
摘要:
AndroidManifest.xml中uses-sdk:有警告如下:Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details.作为一个有代码强迫症的人自然是容不得警告的,谷歌一下找到答案,警告的意思是说targetSdkVersion版本不是最新的,改成最新的就可以了. 阅读全文
为什么EditText的点击事件需要点击两次才能触发
2013-10-15 11:10 by 默契., 2828 阅读, 收藏,
摘要:
前两天做应用的时候TextView点击事件一直不正常,需要点击两次才能触发,今天发现是因为我设置了android:focusableInTouchMode="true"这个属性,导致了点击事件被拦截了.以前为EditText做点击事件的时候也有这个问题,原理其实是一样的; 阅读全文
HorizontalScrollView去滚动条和让子元素的fill_parent生效
2013-10-15 10:05 by 默契., 333 阅读, 收藏,
摘要:
// 让子元素的fill_parent有效setFillViewport(true);// 去掉滚动条setHorizontalScrollBarEnabled(false); 阅读全文
浙公网安备 33010602011771号