0%

Set集合依然有重复

Set集合依然有重复

读set的源码,判断重复的依据是集合里的对象hashcode相等和equal返回了true代表俩对象不一样。

所以我们要重写这俩方法实现去重

TextView低级错误,细节细节

TextView低级错误,细节细节

当我们用.9做背景,动态设置聊天背景(宽度随时长改变)时。。

用”/““作为秒。。1秒怎么都显示不出来。

记得把TextView设置一个最小宽度,否则有些字符被挤看不到。。

在考虑了编码和服务器没得问题,用eclipse查看ui的结构才发现了这个。🤣🤣

另外如果用在Listview的item里,记得设置字体颜色,否则点击item后字体颜色会随系统改变

Win10/WLAN自动获取ip失效

Win10/WLAN自动获取ip失效

自从用了VPN后,电脑WiFi就出了问题,每换一个地方都要手动设置IP。后来百度出了解决办法。亲测有效

桌面右键开始

命令提示符“管理员”

输入 netsh winsock reset   回车 重启

adb error cannot bind to 127.0.0.1:5038:

adb error cannot bind to 127.0.0.1:5038:

出现这种情况多半是端口被其他程序占用了,一般是自己电脑的手机助手程序

我们可以打开cmd输入以下命令查看是谁占用了端口

netstat -nao|findstr 5038


32272为pid,我们可以在任务管理器找到这个程序然后kill,在重启Android studio就好了

前言:有一个音乐播放器的项目,背景需要根据歌曲的封面进行模糊展示,搜罗了很久,找到一个不错的解决方案,不需要我们进行NDK的开发,android帮我们在framework实现好了借鉴

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* 模糊图片
* @param bitmap 原图片
* @param radius 模糊度 0~25
* @param context
* @return 模糊后的图片
*/
public static Bitmap blurBitmap(Bitmap bitmap, float radius, Context context) {
//Create renderscript
RenderScript rs = RenderScript.create(context);

//Create allocation from Bitmap
Allocation allocation = Allocation.createFromBitmap(rs, bitmap);

Type t = allocation.getType();

//Create allocation with the same type
Allocation blurredAllocation = Allocation.createTyped(rs, t);

//Create script
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
//Set blur radius (maximum 25.0)
blurScript.setRadius(radius);
//Set input for script
blurScript.setInput(allocation);
//Call script for output allocation
blurScript.forEach(blurredAllocation);

//Copy script result into bitmap
blurredAllocation.copyTo(bitmap);

//Destroy everything to free memory
allocation.destroy();
blurredAllocation.destroy();
blurScript.destroy();
t.destroy();
rs.destroy();
return bitmap;
}

感谢android,感谢开源

修改gradle属性,加快Android studio编译速度

修改gradle属性,加快Android studio编译速度

1.在自己项目的gradle中加入

android{

...

dexOptions{

maxProcessCount4// this is the default value

javaMaxHeapSize"2g"

}

}


2.在项目的中修改gradle.properties

org.gradle.jvmargs=-Xmx3072m


over!

命令行打印日志

命令行打印日志

adb logcat -s TAG

有时候我们放在System priv-app里的apk,不能再eclipse或as打印。需要用控制台的方式

前言:工作需求,wifi图标根据不同的强度,显示不同的状态.于是想到用图层的方法
####bg.xml

1
2
3
4
5
6
7
<?xml version="1.0" encoding="utf-8"?>

<level-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:maxLevel="0" android:drawable="@drawable/icon_stop_n"></item>
<item android:maxLevel="1" android:drawable="@drawable/icon_pause"></item>

</level-list>

note:android:maxLevel 必须从0递增,顺序错误后只会显示第一张图片
####布局文件

1
2
3
4
5
6
7
<Button
android:id="@+id/bt_pause_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="115px"
android:background="@drawable/bg"
android:tag="play" />

####代码中使用

1
2
3
LevelListDrawable pauseDrawable = (LevelListDrawable) yourwiget
.getBackground();
pauseDrawable.setLevel(1);//根据业务需要,对应图片等级

安卓网站

安卓网站

guolin.tech

Hencodr.com

http://ticktick.blog.51cto.com/823160/1655761  内核分析

title: my new post
date: 2021-02-05 19:04:35
categories: Android日记
tags: Android

前言:啥也不说了,show me the code!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
static List<Integer> intArrayAsList(final int[] a){
if(a == null)
throw new NullPointerException();

retrun new AbstractList<Integer>() {
public Interger get(int i) {
retrun a[i];
}
@Override public Integer set(int i, Integer val){
int oldVal = a[i];
a[i] = val;
retrun oldVal;
}

public int size(){ retrun a.length;}
};
}