安卓开发 易源数据Demo
来源:互联网 发布:js json 遍历 编辑:程序博客网 时间:2024/06/01 09:29
使用易源数据做的Demo 很多有趣的接口我都会把它融合在一起,比较基础;注册账号,使用Apiid+ApiSecret 下载SDK 就可以获取Json返回实例
使用AndroidStudio 插件GsonFormat 快速将实例生成一个JavaBean 不了解的点击https://github.com/zzz40500/GsonFormat 并学习添加到自己的As中
配置文件网络权限:
<uses-permission android:name="android.permission.INTERNET" />
使用的依赖解析:
compile 'com.google.code.gson:gson:2.8.0'
创建的解析Json类:
public class GsonUtils { // 将JSON数据解析生成指定的类 public static <T> T jsonToBean(String jsonResult, Class<T> clz) { Gson gson = new Gson(); T t = gson.fromJson(jsonResult, clz); return t; } // 将一个javaBean生成对应的Json数据 public static String beanToJson(Object obj) { Gson gson = new Gson(); String json = gson.toJson(obj); return json; }}
解析过程:
final String res = new ShowApiRequest("http://route.showapi.com/9-9", Myconstant.Appid, Myconstant.AppSecret). addTextPara("area", "深圳").post();Log.d("WeatherActivity", res);//解析JsonWeather_Basic weather_basic = GsonUtils.jsonToBean(res, Weather_Basic.class);
获取自己需要呈现的数据:(天气预报为例子)
Datestrings.add(weather_basic.getShowapi_res_body().getDayList().get(i).getDaytime().toString());//预报时间Imagestring.add(weather_basic.getShowapi_res_body().getDayList().get(i).getDay_weather_pic().toString());//白天天气图标Temperaturestrings.add(weather_basic.getShowapi_res_body().getDayList().get(i).getDay_air_temperature().toString());//白天气温
呈现的截图:
其他Json接口 异曲同工,根据获取的类型 设置合适的UI界面呈现
项目地址:https://github.com/Small-code-monkey/YiYuanDemo 使用As 2.3.3 gradle:3.3-all
阅读全文
0 0
- 安卓开发 易源数据Demo
- 安卓jni开发demo
- 安卓NDK开发入门DEMO
- 安卓开发 Music小Demo
- 安卓混合开发——Android原生和H5数据交互,详细Demo
- android安卓开发之图片轮播器demo
- 指南针安卓demo
- 安卓定位Demo
- 安卓 闹钟demo
- 安卓的demo
- 安卓指纹识别demo
- 安卓指纹识别demo
- 【安卓开发】安卓实用demo合集,有了这些一个项目轻松搞定
- 安卓开发网络数据请求
- 安卓开发之数据存储SharedPreferences
- 安卓开发 SharedPreferences存储数据
- 安卓开发:解析JSON格式数据
- 安卓开发之数据存储方式
- LeetCode--100. Same Tree
- 聊一聊登录页设计那些事儿
- SpringBoot集成Mybatis+xml格式的sql配置文件
- Java Exception处理逻辑
- informatica数据迁移之Sybase2Oracle
- 安卓开发 易源数据Demo
- 【动态规划23】hdu5036 Explosion(bitset优化)
- mongodb——数据库增删改查
- 22day 单例模式
- 查看APK的签名信息
- wordpress后台创建页面时属性无“模板”选项的问题
- 欧几里得算法
- NodeJs开发环境搭建之Visual Studio Code(二)
- java中String比大小