网络框架-Volley的使用解析Json以及加载网络图片方法

Volley是什么?
Google I/O 大会上,Google 推出 Volley的一个网络框架
Volley适合什么场景?
Volley适合网络通信频繁操作,并能同时实现多个网络通信。

网络框架-Volley网上很多,自己可以自行百度。我这就不提供了

1.Volley的使用解析Json

做一个简单有趣的小软件,一个QQ测凶吉的小软件,使用Volley解析一段地址获取Json并且解析Json显示出来,很简单,也很基础,不过却很直观!
先来看看效果图吧!

截图

步骤

1.申请地址已经key
2.把Volley的jar文件导入工程
3.解析地址获取到json
4.解析json填入

1.申请的Key:8d9160d4a96f2a6b5316de5b9d14d09d
2.接口地址(聚合数据申请的):http://japi.juhe.cn/qqevaluate/qq?key=你申请的Key&qq=374960286
3.将Volley导入工程
4.开工了

注意一定要先添加网络权限: android:name=”android.permission.INTERNET”/>

activity_main.xml


 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.myapplication.MainActivity">


    <RelativeLayout
        android:id="@+id/tab1_rl"
        android:layout_width="match_parent"
        android:layout_height="51dp"
        android:background="#088af7">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="51dp"
            android:layout_centerHorizontal="true"
            android:background="@null"
            android:gravity="center"
            android:text="QQ测凶吉"
            android:textColor="@android:color/white"
            android:textSize="20dp" />
    </RelativeLayout>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10dp"
        android:text="请输入你的QQ号码查询测试结果" />

    <EditText
        android:id="@+id/medittext"
        android:layout_width="fill_parent"
        android:layout_height="45dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_margin="10dp"
        android:background="#f7f7f7"
        android:gravity="center"
        android:hint="请输入正确的QQ号" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/mbut"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            andro
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值