Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛

这次我们用第三方的接口来做一个QQ吉凶的测试项目,代码依然是比较的简单无图无真相直接撸代码了,详细解释都已经写在注释里了activity_main.xml&lt

无图无真相

开始编码吧,详细的解释已经写在注释里了。

活动主文件

LinearLayout xmlns:android=\’http://schemas.android.com/apk/res/android\’

xmlns:tools=\’http://schemas.android.com/tools\’

android:layout_width=\’match_parent\’

android:layout_height=\’match_parent\’

android:orientation=\’垂直\’

编辑文本

android:id=\’@+id/et_qq\’

android:layout_width=\’match_parent\’

android:layout_height=\’wrap_content\’

android:layout_marginTop=\’10dp\’

android:background=\’@drawable/whitebg\’

android:gravity=\’中心\’

android:hint=\’请输入您的QQ号\’

android:lines=\’3\’

android:numeric=\’整数\’ /

按钮

android:id=\’@+id/btn_go\’

android:layout_width=\’match_parent\’

android:layout_height=\’wrap_content\’

android:layout_margin=\’15dp\’

android:layout_marginTop=\’5dp\’

android:background=\’@drawable/graybg\’

android:text=\’求佛\’/

文本视图

android:id=\’@+id/tv_conclusion\’

android:layout_width=\’wrap_content\’

android:layout_height=\’wrap_content\’

android:layout_margin=\’15dp\’

android:layout_marginBottom=\’5dp\’

android:layout_marginTop=\’5dp\’

android:text=\’结果\’

android:textSize=\’18sp\’/

看法

android:layout_width=\’match_parent\’

android:layout_height=\’1dp\’

android:background=\’#fff\’/

文本视图

android:id=\’@+id/tv_analysis\’

android:layout_width=\’wrap_content\’

android:layout_height=\’wrap_content\’

android:layout_margin=\’15dp\’

android:layout_marginTop=\’5dp\’

android:text=\’分析\’

android:textSize=\’18sp\’/

com.lgl.qq.WaterRippleView

android:layout_width=\’match_parent\’

android:layout_height=\’0dp\’

android:layout_weight=\’1\’

/com.lgl.qq.WaterRippleView

/线性布局

主要活动

com.lgl.qq 包;

导入org.json.JSONException;

导入org.json.JSONObject;

导入android.app.Activity;

导入android.os.Bundle;

导入android.view.View;

导入android.view.View.OnClickListener;

导入android.widget.Button;

导入android.widget.EditText;

导入android.widget.TextView;

导入android.widget.Toast;

导入com.android.volley.Request.Method;

导入com.android.volley.RequestQueue;

导入com.android.volley.Response;

导入com.android.volley.Response.Listener;

导入com.android.volley.VolleyError;

导入com.android.volley.toolbox.StringRequest;

导入com.android.volley.toolbox.Volley;

公共类MainActivity 扩展Activity 实现OnClickListener {

私人EditText et_qq;

私有按钮btn_go;

私人TextView tv_conclusion,tv_analysis;

@覆盖

protected void onCreate(Bundle savingInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

初始化视图();

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛

}

私有无效initView() {

//初始化控件

et_qq=(EditText) findViewById(R.id.et_qq);

btn_go=(按钮) findViewById(R.id.btn_go);

btn_go.setOnClickListener(this);

tv_conclusion=(TextView) findViewById(R.id.tv_conclusion);

tv_analysis=(TextView) findViewById(R.id.tv_analysis);

}

@覆盖

公共无效onClick(查看v){

开关(v.getId()) {

案例R.id.btn_go:

if (et_qq==null) {

Toast.makeText(MainActivity.this, \’佛陀不留QQ号怎么能算尼姑?\’,

Toast.LENGTH_LONG).show();

} 别的{

Volley_Get();

}

休息;

}

}

私人无效Volley_Get() {

//获取输入的QQ号码

String qq=et_qq.getText().toString();

//第三方接口

字符串url=\’http://japi.juhe.cn/qqevaluate/qq?key=8d9160d4a96f2a6b5316de5b9d14d09dqq=\’

+ QQ;

RequestQueue 队列=Volley.newRequestQueue(this);

StringRequest 请求=new StringRequest(Method.GET, url,

新的侦听器字符串(){

//成功

@覆盖

公共无效onResponse(字符串json){

//Volley解析得到json

Volley_Json(json);

}

}, 新的Response.ErrorListener() {

//失败

@覆盖

公共无效onErrorResponse(VolleyError错误日志){

Toast.makeText(MainActivity.this,

\’失败:\’ + errorLog.toString(), Toast.LENGTH_LONG)。展示();

}

});

队列.添加(请求);

}

//解析json

私人无效Volley_Json(字符串json){

尝试{

//获取JSONObject对象

JSONObject jsonObject=新JSONObject(json);

//解析结果

JSONObject 对象=jsonObject.getJSONObject(\’结果\’);

//解析数据

JSONObject object1=object.getJSONObject(\’data\’);

tv_conclusion.setText(\’结果:\’ + object1.getString(\’结论\’));

tv_analysis.setText(\’分析:\’ + object1.getString(\’分析\’));

} catch (JSONException e) {

Toast.makeText(MainActivity.this, \’施主不留QQ号,佛怎么能算尼姑?\’,

Toast.LENGTH_LONG).show();

e.printStackTrace();

}

}

}

这里有几点需要说明一下

1、项目中的水波纹特效请参见:【Android特效专辑(一)——水波纹转场特效(首页)】(http://blog.csdn.net/qq_26787115/article/details/50439020)

2.项目中的按钮样式:

?xml 版本=\’1.0\’编码=\’utf-8\’?

形状xmlns:android=\’http://schemas.android.com/apk/res/android\’

固体android:color=\’#ffDEDEDE\’ /

角android:radius=\’2.0dp\’ /

/形状

3.项目中的EditText样式

?xml 版本=\’1.0\’编码=\’utf-8\’?

形状

xmlns:android=\’http://schemas.android.com/apk/res/android\’

固体android:color=\’#ffffffff\’/

角android:radius=\’2.0dp\’/

/形状

用户评论

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
冷青裳

Google的Volley框架,用来测试QQ好坏,这想法太妙了!南无阿弥陀佛,希望结果顺利!

    有18位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
余温散尽ぺ

用Volley框架测试QQ,这操作很厉害啊,期待结果!

    有7位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
夏以乔木

南无阿弥陀佛,希望测试结果能给QQ带来一些改进!

    有6位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
我的黑色迷你裙

Volley实战QQ好坏测试,感觉很专业,期待看到最终结果!

    有10位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
等量代换

用Volley框架来测试QQ,感觉很有意思,希望结果能让我眼前一亮!

    有7位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
拉扯

南无阿弥陀佛,希望这个测试能帮助QQ变得更好!

    有15位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
青衫负雪

Volley框架,测试QQ,这组合很不错!

    有8位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
情深至命

期待看到Volley实战QQ测试结果,南无阿弥陀佛!

    有9位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
孤岛晴空

希望这个测试结果能给QQ带来一些新的启发!

    有6位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
志平

Google Volley,QQ,南无阿弥陀佛,这三个词组合在一起很有意思!

    有5位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
若他只爱我。

感觉这个测试很有意义,希望结果能对QQ有所帮助!

    有8位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
男神大妈

南无阿弥陀佛,希望测试顺利,结果能让人满意!

    有17位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
顶个蘑菇闯天下i

用Volley框架测试QQ,这想法很新颖,期待结果!

    有9位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
迷路的男人

Volley框架,QQ,南无阿弥陀佛,这组合很强大!

    有13位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
自繩自縛

希望测试结果能帮助QQ提升用户体验!

    有12位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
淡淡の清香

南无阿弥陀佛,祝测试顺利!

    有16位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
一点一点把你清空

Google Volley测试QQ,感觉很有意思,期待结果!

    有18位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
拥菢过后只剰凄凉

期待看到这个测试结果,南无阿弥陀佛!

    有15位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
昂贵的背影

希望这个测试结果能对QQ的性能有所提升!

    有16位网友表示赞同!

Google官方网络框架Volley实战QQ好坏测试,南无阿弥陀佛
心贝

南无阿弥陀佛,希望测试结果能给QQ带来更多改进!

    有16位网友表示赞同!

原创文章,作者:xiaobian,如若转载,请注明出处:https://www.xinyuspace.com/6731.html

(0)
xiaobianxiaobian
上一篇 2024年9月1日
下一篇 2024年9月1日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注