介绍

首页字典

更多

包含内容

内容对应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'//recyclerviewimplementation 'androidx.recyclerview:recyclerview:1.2.1'//cardviewimplementation '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.Contextimport com.yechaoa.yutilskt.YUtilsimport java.io.BufferedReaderimport java.io.IOExceptionimport java.io.InputStreamReaderclass 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" />private lateinit var mapBeanList: MutableListval str = JsonFileUtil.loadFile(this, "word.json")val mapBeanListType: Type = object : TypeToken?>() {}.typemapBeanList = 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}

代码详情

https://gitee.com/juer2017/xinhuazidian

下载

用手机浏览器输入这个网址:https://spark.appc02.com/4jc9

或者gitee下载:https://gitee.com/juer2017/xinhuazidian/blob/master/app/release/app-release.apk