# Xinhuazidian **Repository Path**: juer2017/xinhuazidian ## Basic Information - **Project Name**: Xinhuazidian - **Description**: 新华字典,成语词典,歇后语,唐诗三百首,三字经,百家姓,千字文,论语,朱子家训等。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 3 - **Created**: 2023-02-24 - **Last Updated**: 2026-01-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 不联网字典 ### 下载地址 [新华字典](https://fir.xcxwo.com/4jc9) #### 包含内容 | 内容 | 对应Json数据文件 | |---------|------------------------| | 百家姓 | baijiaxing.json | | 曹操诗集 | caocao.json | | 弟子规 | dizigui.json | | 成语 | idiom.json | | 论语 | lunyu.json | | 纳兰性德诗集 | nalanshiji.json | | 千家诗 | qianjiashi.json | | 千字文 | qianziwen.json | | 三字经-传统版 | sanzijing_ct.json | | 三字经-新版 | sanzijing_xb.json | | 诗经 | shijing.json | | 水墨唐诗 | shuimotangshi.json | | 唐诗三百首 | tangshisanbaishou.json | | 新华字典 | word.json | | 歇后语 | xiehouyu.json | | 朱子家训 | zhuzijiaxun.json | #### 依赖库 我这里用了应用更新,所以更新的时候需要网络,其他数据读取本地json数据不需要联网 ``` dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.core:core-ktx:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.4.+' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' //recyclerview implementation 'androidx.recyclerview:recyclerview:1.2.1' //cardview implementation 'androidx.cardview:cardview:1.0.0' //gson数据解析 implementation 'com.google.code.gson:gson:2.10.1' //沉浸状态栏基础依赖包,必须要依赖 implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2' implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2' //工具库 implementation 'com.github.yechaoa.YUtils:yutilskt:3.2.2' //glide图片加载 implementation 'com.github.bumptech.glide:glide:4.15.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.15.0' //网络请求所需 implementation "io.reactivex.rxjava2:rxjava:2.2.8" implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' implementation 'com.squareup.retrofit2:retrofit:2.6.2' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0' implementation 'com.squareup.retrofit2:converter-gson:2.4.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1' //下载更新 implementation 'com.github.azhon:AppUpdate:3.0.5' } ``` #### 权限 ``` ``` #### 本地json数据加载与解析 ``` import android.content.Context import com.yechaoa.yutilskt.YUtils import java.io.BufferedReader import java.io.IOException import java.io.InputStreamReader class JsonFileUtil { companion object { fun loadFile(context: Context, fileName: String): String { val stringBuilder = StringBuilder() try { val inputStream = context.resources.assets.open(fileName) val isr = InputStreamReader(inputStream) val reader = BufferedReader(isr) var jsonLine: String? while (reader.readLine().also { jsonLine = it } != null) { stringBuilder.append(jsonLine) } reader.close() isr.close() inputStream.close() YUtils.hideLoading() } catch (e: IOException) { e.printStackTrace() YUtils.hideLoading() } return stringBuilder.toString() } } } ``` ``` private lateinit var mapBeanList: MutableList val str = JsonFileUtil.loadFile(this, "word.json") val mapBeanListType: Type = object : TypeToken?>() {}.type mapBeanList = Gson().fromJson(str, mapBeanListType) initAdapter(mapBeanList) private fun initAdapter(list: MutableList) { //设置布局排列方式 val staggeredGridLayoutManager = StaggeredGridLayoutManager(2, LinearLayoutManager.VERTICAL) binding.rv.layoutManager = staggeredGridLayoutManager //加载适配器 moreAdapter = MoreAdapter(this, list) binding.rv.adapter = moreAdapter } ```