目录
Android中文乱码
reload和cnvert区别
Android中文乱码
reload和cnvert区别
在你所在的activity中设置编码格式,一般采用utf,有的采用gbk数据一般是别人下发数据你进行接收,那么就必须采用gbk进行格式转化;
上图中reload是你当前视图中看到的代码格式转换;
cnvert是将你跑应用时应用中文字显示的格式;
还有一种万能手法:
在build.gradle中添加 在android 目录中:compileOptions.encoding = "GBK”
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "29.0.2"
compileOptions.encoding = "GBK"
defaultConfig {
applicationId "cn.linhanqing.xinsheng"
minSdkVersion 14
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
}
加入: compileOptions.encoding = "GBK"