
Android
peachesTao
一天一点点,时刻保持紧迫感!
展开
-
Android中TextView文字居中
Android中TextView文字居中1、水平垂直居中: 在xml文件设置:android:gravity="center"2、垂直居中水平居左 在xml文件设置:android:gravity="center| left"3、垂直居中水平居右 在xml文件设置:android:gravity="center | right"4、垂直居上水平居中 在xml文件设置:android:gravity="center| top"...原创 2020-07-24 22:59:24 · 18875 阅读 · 0 评论 -
OkHttp使用
OkHttp3.0下载文件1 首先要在app/build.gradle中添加依赖,另外注意清单文件中打开相应网络访问权限如: implementation 'com.squareup.okhttp3:okhttp:3.14.1' implementation 'com.squareup.okhttp3:logging-interceptor:3.14.1' implementation 'com.squareup.okio:okio:1.6.0'2 创建一个OkHttp转载 2020-05-19 19:57:39 · 419 阅读 · 0 评论 -
Lint found fatal errors while assembling a release target
Lint found fatal errors while assembling a release target. 问题的解决方案此问题发生在编译为 release 版本时,出现错误提示如下:Lint found fatal errors while assembling a release target.To proceed, either fix the issues identified by lint, or modify your build script as fol..转载 2020-05-19 19:55:47 · 1057 阅读 · 1 评论 -
android.os.FileUriExposedException: file:///storage/emulated.. exposed beyond app through Intent.get
安卓7.0遇到 android.os.FileUriExposedException: file:///storage/emulated.. exposed beyond app through Intent.getData()1、在AndroidManifest.xml中添加如下代码<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/r.转载 2020-05-19 19:52:15 · 698 阅读 · 0 评论 -
android 该文件包与具有同一名称的现有文件包存在冲突
问题:安装应用提示 该文件包与具有同一名称的现有文件包存在冲突。 无法安装可能的原因:新版的软件的versionCode和现有版本的软件相同解决方案:修改新版本软件的versionCode。为了不用每次发布都手工修改,通过代码可以设置为自动增加+1方法如下:第一步:创建一个文件,名字就叫version.properties(当然,这个不一定要这么写),位置和build.gradle文件同级,app这个是我的执行module,文件里面的内容是:VERSION_CODE=.转载 2020-05-19 19:50:39 · 7496 阅读 · 0 评论 -
error: failed to read PNG signature: file does not start with PNG signature
android studio打包错误Error:error: failed to read PNG signature: file does not start with PNG signatureliuhaha1015 2019-06-06 17:41:03 519 收藏展开打包apk时报:Error:error: failed to read PNG signature: file does not start with PNG signature.android studio错误:..转载 2020-05-19 19:42:40 · 1814 阅读 · 0 评论 -
android Listview固定列头
Android Listview固定列头背景当Listview数据行超过固定固定高度时会出现滚动条,当向下滚动时列头会跟着滚动,影响用户体验,如何在向下滚动时固定列表不动呢?在网上查阅相关资料有的通过监听滚动距离来实现,综合各种信息最后采用了单独控件做列头,独立于listview,无论listview向下滚动单独控件列头都不会跟着向下滚动,间接达到了固定列头的效果。实现步骤:1、...原创 2020-03-18 18:13:03 · 2227 阅读 · 3 评论 -
Android学习--关于setWidth()和setHeight()没反应的问题
在android开发过程中,对于控件的高度,宽度,虽然在xml中用android:layout_height="match_parent"设置了高度(match_parent和fill_parent是一样的,2.2版本后就用match_parent代替fill_parent了。)但有时,程序需要,必须在代码里,动态设置控制的高度或宽度。我想当然的用setHeight(100);设置了高度,以为...转载 2019-12-27 11:07:34 · 779 阅读 · 1 评论 -
在安卓中使用lambda报错(Lambda expressions are not supported at language level '7')解决办法
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本文链接:https://blog.csdn.net/weixin_43373239/article/details/88741896本人电脑里的Java环境是java1.8,在编写java项目时可以正常使用lambda表达式,但是今天在Android Studio中编写时,发现抱错,编译器...转载 2019-11-29 09:55:41 · 1719 阅读 · 0 评论 -
Android 打包报错 TaskExecutionException: Execution failed for task ':app:lintVitalRelease'
Android 打包报错 TaskExecutionException: Execution failed for task ':app:lintVitalRelease'在app/bulid.gradle (Module:)//添加如下配置就ok了android {....lintOptions { checkReleaseBuilds false abor...转载 2019-10-28 14:34:20 · 314 阅读 · 0 评论 -
Android获取屏幕高度宽度的方法
WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);int width = wm.getDefaultDisplay().getWidth();int height = wm.getDefaultDisplay().getHeight();获取到的单位是像素 px...转载 2019-06-17 12:48:51 · 4816 阅读 · 0 评论 -
android 动态设置margin
代码中不能直接给控件设置margin属性,可以通过layoutParam来设置这里是用ConstraintLayout布局布局xml:<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.and...原创 2019-06-17 12:58:18 · 4986 阅读 · 0 评论 -
adaemon not running starting it now on port 5037 ADB server didn't ACK
问题:使用adb devices查看连接设备时报错:* daemon not running. starting it now on port 5037 *ADB server didn't ACK* failed to start daemon *error: cannot connect to daemon解决方案:一开始以为是5037端口被别的程序占用了,用nets...原创 2019-06-23 10:44:58 · 514 阅读 · 0 评论 -
HttpURLConnection 表单提交数据
转载于:https://blog.csdn.net/yongwoozzang/article/details/83029128HttpURLConnection x-www-form-urlencoded public static String Post(String httpUrl, String data) { PrintWriter out = null; InputStr...转载 2019-08-02 18:58:44 · 4452 阅读 · 2 评论 -
Android布局文件夹拆分多个子文件夹
转载于:https://www.jianshu.com/p/fcc831e87b3d混乱的布局文件相信很多做Android开发的同学都有过这样的困扰:随着项目越来越多,布局文件越来越多,layout文件夹下面的文件也越来越多,显得混乱不堪。那么,是否有办法将layout文件拆分为几个小文件夹,根据模块功能存放布局文件呢?答案是:能!!!解决方案利用Gradle脚本可以指定Reso...转载 2019-08-08 09:58:32 · 1315 阅读 · 0 评论 -
Android Studio修改项目名(快速)
转载于:https://blog.csdn.net/qq_36347817/article/details/81087898Android Studio修改项目名(快速)2018年07月17日 20:29:32志悠自在阅读数 2391版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36347817/article/detai...转载 2019-08-01 17:46:24 · 7923 阅读 · 2 评论 -
android 动态改变listview的内容
android 动态改变listview的内容转载于:https://www.cnblogs.com/wuyou/p/3566269.html本文模拟:点击一个按钮,为已有的listview添加一行数据<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schem...转载 2019-08-06 20:37:45 · 2052 阅读 · 0 评论 -
java.lang.InstantiationException: java.lang.Class com.android.tools.ir.runtime.IncrementalChange
问题:java.lang.InstantiationException: java.lang.Class<com.android.tools.ir.runtime.IncrementalChange> cannot be instantiated解决方案:File->Settings->Build,Exceution,Deployment->In...原创 2019-08-15 18:31:45 · 998 阅读 · 0 评论 -
Android如何设置ListView不可点击
Android如何设置ListView不可点击在Android开发的时候我们有可能遇到一些需求在ListView里边还设置按钮,但是在点击按钮的时候,系统会首先消耗掉ListView的点击事件,使得我们在点击按钮的时候并没有效果。那么怎样设置才能正确的达到想要的效果呢方法:在相应的Adapter里边加上这些代码即可。@Override public boo...转载 2019-08-20 23:06:15 · 1052 阅读 · 0 评论 -
Android 上传文件到 FTP 服务器
实现背景近期接触到一个需求,就是将文件从Android系统上传到FTP服务器,虽然之前接触过FTP服务器,了解基本的使用流程,但是将此流程从使用习惯转化为代码实现还是有一定难度的。但是基本的流程还是比较清楚的:1.在Android手机上创建一个FTP客户端 2.设置host及端口建立与FTP服务器的连接 3.使用用户名和密码登录FTP服务器 4.更改目录,将当前客户端指向的服务端的...转载 2019-08-28 12:40:58 · 2001 阅读 · 0 评论 -
Android(Java)删除非空文件夹
Java 似乎没有提供一个删除非空文件夹的API.所以删除整个文件夹的操作需要我们自己来做.其实文件夹拷贝, 文件夹删除, 本质上是一个"文件树"遍历的问题.粗糙的人 用递归实现. 个人认为递归绝对不能用在商业代码上.下面示范一下我的删除文件夹操作的Java代码:/*** * 删除文件或者文件夹 * @param f * @return 成功 返回true, 失...转载 2019-08-29 12:48:46 · 638 阅读 · 0 评论 -
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
问题No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android解决方案第一步:http://tools.android-studio.org/ 找到NDK包 根据不同的系统选择不同的包下载第二步:解压后将toolchains下面的mi...原创 2019-02-28 10:11:47 · 1047 阅读 · 0 评论 -
android像素db转px或者px转dp(有案例)
转载于:https://blog.csdn.net/a876434758/article/details/47002341源码地址:http://download.csdn.net/detail/a876434758/8922609截图:部分源码:/*** 转换工具类** @author zihao 2014-09-17**/public class D...转载 2019-06-17 12:44:00 · 958 阅读 · 0 评论 -
requestFocus无效
当requestFocus不能立马起作用时…转载于:https://blog.csdn.net/jjzhoujun2010/article/details/38040297 不知道各位有没有遇到过这样的情况: 第一次一个apk界面,然后本来想在某处requestFocus()使之获得焦点来显示的,但是直接调用却不行,如图1所示。出现这样的现象是Android加载刷新UI的时...转载 2019-06-20 22:29:06 · 1767 阅读 · 0 评论 -
android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
为了实现是定义title,我们会加上requestWindowFeature(Window.FEATURE_CUSTOM_TITLE)和getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.title)这两句代码protected void onCreate(Bundle savedInstanceState) {...原创 2019-05-15 22:39:35 · 492 阅读 · 0 评论 -
【Android】SQLite的工具类 ---- 通过反射把Cursor封装到VO对象
【Android】SQLite的工具类 ---- 通过反射把Cursor封装到VO对象转载于:https://blog.csdn.net/richnaly/article/details/7790246在写DAO层时,觉得从Cursor里一个一个的取出字段值再装到VO(值对象)里太麻烦了,就写了一个工具类,用到了反射,可以把查询记录的值装到对应的VO里,也可以生成该VO的List。...转载 2019-04-11 22:37:50 · 397 阅读 · 0 评论 -
java.net.SocketException:socket failed:EACCES (Permission denied)
问题:java.net.SocketException: socket failed: EACCES (Permission denied)解决方案:在AndroidManifest.xml总的manifest中的节点下增加<uses-permission android:name="android.permission.INTERNET" />,注意:必须在manif...原创 2019-03-01 13:36:22 · 6133 阅读 · 2 评论 -
Androidstudio中添加jar包的方法
https://blog.csdn.net/zhw1551706847/article/details/77709142转载 2019-02-28 16:31:26 · 203 阅读 · 0 评论 -
窗口所有元素都挤在左上角
问题:窗口中添加所有元素:按钮、文本框 运行时都挤在左上角解决方案:设计界面 点“星星“图标原创 2019-02-28 15:10:56 · 1382 阅读 · 2 评论 -
Android Realm数据库使用指南
Android Realm数据库使用指南转载于:https://www.cnblogs.com/mengdd/p/android-realm-database-guides.htmlRealm数据库, 目前有Java, Objective‑C, React Native, Swift, Xamarin的几种实现, 是一套用来取代SQLite的解决方案.本文面向Android开发, 所以...转载 2019-01-09 13:09:04 · 1394 阅读 · 0 评论 -
Android 数据库对比
Android 数据库对比转载于:https://blog.csdn.net/u010134293/article/details/58590092一、常见数据库介绍 GreenDao 是为Android设计的对象关系映射(ORM)工具。它提供了对象到关系型数据库SQLite的相应接口。为了在Android工程中使用greenDao,需要创建另一个“生成器”工程,它的任务是在你的工程...转载 2019-01-09 11:57:40 · 6865 阅读 · 0 评论 -
This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime
问题:This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime 此问题虽然不影响编译,但实际控件位置不会跟设计时一样解决方案:选中“按钮1”,添加约束 ...原创 2019-01-08 16:17:56 · 1313 阅读 · 0 评论 -
Failed to resolve: com.android.support:appcompat-v7:27+
问题:解决方案:原创 2019-01-07 15:02:28 · 931 阅读 · 0 评论 -
android sqllite使用笔记
android在使用sqllite做update操作时,如果要将某个字段值在原来的基础上减少指定的数量,我们会用update语句update qx_doc set act_qty=act_qty-100 where doc_no=‘001’有两种方法实现:方法一:封装好的update方法ContentValues cv=new ContentValues();cv.put("a...原创 2019-05-14 22:22:30 · 376 阅读 · 0 评论 -
Android Studio使用系统自带图标
我用的Android Studio 版本是2.3,其他版本或许会有稍许差异。1、drawable右键->New->Image Asset2、选择Clip Art,然后点击弹出图片源3、找到你要的图片4、可以看到图片已经获取5、在项目中使用图标...原创 2019-05-14 22:46:20 · 12209 阅读 · 2 评论 -
android 解决键盘弹出后输入框被下方控件遮盖
问题:app 输入框获得焦点后软键盘弹出时输入框下方的控件会遮挡输入框,导致无法输入。1、正常状态:2、备注单号输入框获得焦点:这时备注单号被下方的“新建“按钮挡住了一部分解决方案:在AndroidManifest.xml中的当前activity中添加android:windowSoftInputMode="adjustPan"属性该属性的意思是:1、...原创 2019-06-14 14:09:43 · 4367 阅读 · 0 评论 -
Android实现点击AlertDialog上按钮时不关闭对话框的方法
转载于:https://www.jb51.net/article/60845.htm这篇文章主要介绍了Android实现点击AlertDialog上按钮时不关闭对话框的方法,涉及设置监听的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下本文实例讲述了Android实现点击AlertDialog上按钮时不关闭对话框的方法。分享给大家供大家参考。具体如下:开发过程中,有时候会有这样的需...转载 2019-06-02 13:30:14 · 2136 阅读 · 0 评论 -
android studio 代码打断点红点不显示
问题:android studio 代码打断点红点不显示解决方案:1、Clean Project2、Make Project做完上述两个步骤还是无效3、用debug模式启动调试,启动后再打断点小红点出现,关闭debug后也可以打断点。至此问题解决。...原创 2019-06-06 10:47:44 · 1999 阅读 · 0 评论 -
Android优雅地处理按钮重复点击
App中,有很大一部分场景是点击按钮,向服务端提交数据,由于网络请求需要时间,用户很可能会多次点击,造成数据重复提交,造成各种莫名其妙的问题。因此,防止按钮多次点击,是Android开发中一个很重要的技术手段。转载于:https://www.jianshu.com/p/7b354eb8d0d3以前的处理方式网上查找到的,或者你可能会想到的方法大概有这些:1.每个按钮点击事件中...转载 2019-06-12 15:14:05 · 598 阅读 · 1 评论 -
Android ListView简单例子
ListView是Android软件开发中非常重要组件之一,基本上是个软件基本都会使用ListView ,今天我通过一个demo来教大家怎么样使用ListView组件activity_main.xml<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=...转载 2019-05-30 13:19:37 · 824 阅读 · 0 评论