Android开发问题积累 <加载在线Gif><WebView无法加载网页图片>
在线Gif加载
解决办法
Glide完美解决
Glide.with(context).load(pic).placeholder(R.drawable.loading).into(imageView);
pic: url地址
R.drawable.loading: gif加载之前图片
imageView:目标imageview
Intent调用图库
使用L版本手机的时候,通过Intent调用图库,选择图片后出现”不支持的媒体类型”或者是”Failed to read row 0, column 6 from a CursorWindow which has 1 rows, 6 columns”。
由于对数据库这一款疏于了解,不能很快的定位出这个问题,首先想到的办法就是将出问题的文件不要暴露在用户眼前。
解决办法
Intent intent = null;
if (Build.VERSION.SDK_INT < 19)
{
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
}
else
{
intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
}
不同的Android版本,选择系统图库中图片的方式有点差别,这个是需要注意的,Google不断更新API肯定是有原因的,所以,Android版本的兼容性问题是迭代开发和维护工作中不可避免的。单看代码是比较简单,但是当开发者不知道的时候,这个问题可能就会浪费很多时间。
AlertDialog获取PositionButton,NeturalButton 和 NegativeButton,一定要先调用show()方法
解决办法
dialog.show();//注意 必须先调用这个,否则下面会报空指针异常
if(xxxxx) { dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setVisibility(GONE);
} else { dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setVisibility(VISIBLE);
}
L版本上Toast无法显示
解决办法
- L版本上通知管理中,关闭了对应应用的通知权限,去“设置”-> “通知管理”中打开即可
- 避免因为权限问题导致Toast无法显示,可以尝试自定义完成类似Toast的功能
TextView走马灯
解决办法
TextView tv = new TextView(activity);
tv.setText("XXXXXXXXXXXX");
tv.setSingleLine(true);
tv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
tv.setMarqueeRepeatLimit(-1);
tv.setFocusable(true);
tv.setFocusableInTouchMode(true);
tv.setHorizontallyScrolling(true);
tv.requestFocus();
使用系统ACTION_SEND 发送文字或者图片
解决办法
发送文字
String message = "This is a sharing Text";
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, message);
this.startActivity(shareIntent);
发送图片
/* localqrcode是一个bitmap对象*/
String pathofBmp = Images.Media.insertImage( activity.getContentResolver(), localqrcode,
"title", null);
Uri bmpUri = Uri.parse(pathofBmp);//获取本地Uri
Intent intent= new Intent( android.content.Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_STREAM, bmpUri);//流类型
intent.setType("image/png");
activity.startActivity(intent.createChooser(intent, "选择"));
调用系统资源
解决办法
/*
获取导航栏高度
*/
private int getNavigationBarHeight() {
boolean hasNavigationBar = getResources().getBoolean(Resources.getSystem().getIdentifier("config_showNavigationBar", "bool", "android"));
if(hasNavigationBar) {
return getResources().getDimensionPixelSize(Resources.getSystem().getIdentifier("navigation_bar_height", "dimen","android"));
}
return 0;
}
通过
Resources.getSystem().getIdentifier(“config_showNavigationBar”, “bool”, “android”));
这类方式获取ID,然后通过正常的资源使用方式使用即可
Okhttp异常
Okhttp异常:
System.err: java.lang.IllegalStateException: closed
System.err: at okio.RealBufferedSource.rangeEquals(RealBufferedSourc
System.err: at okio.RealBufferedSource.rangeEquals(RealBufferedSourc
System.err: at okhttp3.internal.Util.bomAwareCharset(Util.java:397)
System.err: at okhttp3.ResponseBody.string(ResponseBody.java:173)
解决办法
Response response = okHttpClient.newCall(request).execute();
这里返回的response一般我们后面就会执行response.body().string(),
但是如果连续调用两次response.body().string(),就会出现如上的错误
actionBar.setDisplayHomeAsUpEnabled(true);后如何修改返回图标
解决办法
actionBar.setHomeAsUpIndicator(R.drawable.__picker_back);
toolbar上menu的标题字体颜色如何修改
解决办法
style.xml文件中添加<item name="actionMenuTextColor">#ffffff</item>
WebView无法显示图片
解决办法
webView.getSettings().setBlockNetworkImage(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
Unable to execute dex: method ID not in [0, 0xffff]: 65536
解决办法
Eclipse: dex.force.jumbo=true
Android Studio : multiDexEnabled true
Android开发问题积累 <加载在线Gif><WebView无法加载网页图片>的更多相关文章
- Android 开发日常积累
Android 集合 Android 开源项目分类汇总 扔物线的 HenCoder 高级 Android 教程 hencoder HenCoder:给高级 Android 工程师的进阶手册 Andro ...
- android开发(29) 自定义曲线,可拖动,无限加载
项目需要 做一个曲线,该曲线的数据时不断加载的.如下图,当不断向左拖动时,图形曲线要随着拖动移动,并在拖动到边界时需要加载更多数据. 先看步骤: 1.在Activity里放一个surfaceView ...
- 《ArcGIS Runtime SDK for Android开发笔记》——(12)、自定义方式加载Bundle格式缓存数据
随着ArcGIS 10.3的正式发布,Esri推出了新的紧凑型缓存格式以增强用户的访问体验.新的缓存格式下,Esri将缓存的索引信息.bundlx包含在了缓存的切片文件.bundle中.具体如下图所示 ...
- Android开发学习总结(四)——Eclipse在线安装ADT插件
要想使用Eclipse开发Android应用,首先要安装一个ADT插件,在此记录一下在Eclipse中采用在线安装的方式ADT插件,我使用的Eclipse版本是:eclipse-jee-luna-SR ...
- android开发之网络棋牌类在线游戏开发心得(服务器端、Java) 好文章值得收藏
标签: android服务器 2013-10-09 17:28 3618人阅读 评论(0) 收藏 举报 分类: android(11) 转自:http://blog.csdn.net/bromon/a ...
- 《ArcGIS Runtime SDK for Android开发笔记》
开发笔记之基础教程 ArcGIS Runtime SDK for Android 各版本下载地址 <ArcGIS Runtime SDK for Android开发笔记>——(1).And ...
- 【转】Android开发笔记(序)写在前面的目录
原文:http://blog.csdn.net/aqi00/article/details/50012511 知识点分类 一方面写写自己走过的弯路掉进去的坑,避免以后再犯:另一方面希望通过分享自己的经 ...
- [置顶]
Android开发百科全书
友情提示根据目录 快速查找问题 %1$s %1$d Android string 1.整型,比如"我今年23岁了",这个23是整型的.在string.xml中可以这样写,<s ...
- 《ArcGIS Runtime SDK for Android开发笔记》——(11)、ArcGIS Runtime SDK常见空间数据加载
ArcGIS Runtime SDK for Android 支持多种类型空间数据源.每一种都提供了相应的图层来直接加载,图层Layer是空间数据的载体,其主要继承关系及类型说明如下图所示: 转载请注 ...
随机推荐
- cobbler 自定义安装系统
1.自定义安装系统(根据mac地址)--name=定义名称--mac=客户端的mac地址--ip-address=需求的ip--subnet=掩码 --gateway=网关--interface=网口 ...
- JS: 防抖节流
防抖节流 防抖(debounce) 先来看看下面的代码: //触发滚动事件,num 就加1 let num = 0; function incNum() { console.log('鼠标滚动中'); ...
- WinForm—控制文本框只能输入整数(包括小数)
//控制控件输入的是正数(包括小数) private void txt_Weight_KeyPress(object sender, KeyPressEventArgs e) { //第一步:判断输入 ...
- 03——Solr学习之Solr的使用(不会用)
1.先放上次在linux搭建成功的solr管理UI界面 2.有个很蛋疼的问题我就要吐槽一下了 由于没接触过solr这玩意,在百度上一顿操作搜索怎么用,怎么导入数据,建索引库什么的,看了一大片别人的博客 ...
- 程序模拟HTTP请求
1. 使用HttpClient 前面拼接StringContent string strContent = "client_id=client&client_secret=secre ...
- HUE配置文件hue.ini 的mapred_clusters模块详解(图文详解)(分HA集群和非HA集群)
不多说,直接上干货! 我的集群机器情况是 bigdatamaster(192.168.80.10).bigdataslave1(192.168.80.11)和bigdataslave2(192.168 ...
- Eclipse Git 克隆项目的时候出现Internal error; consult Eclipse error log
在使用git下载代码时偶尔会遇到 Internal error; consult Eclipse error log 这个报错. 简述下个人解决思路: Eclipse 错误日志报错为:org.ecl ...
- bootstrap table 修改table内容时设置表头与表格对齐
第一:取消表头初始化解决表头和内容不对齐问题,取消后表头将不固定. 在你对应的js(bootstrap-table.min.js或bootstrap-table.js,我用的bootstrap-tab ...
- Go 压测
1. 单测 + 压测 压测 go test -bench=. -benchmem 单元测试 go test -v . 2. pprof + 火焰图(查看cpu占用,内存占用) 嵌入代码 import ...
- CentOS6.5安装php7+nginx+mysql实现安装WordPress
安装php7+nginx参考该博客http://blog.csdn.net/whatday/article/details/50645117 安装php7参考http://blog.csdn.net/ ...