From ea1cee590b8b1c9d67d1d25773fb0bbb30dc6a1f Mon Sep 17 00:00:00 2001 From: Hackergeek <1224085894@qq.com> Date: Thu, 12 May 2016 13:13:58 +0800 Subject: [PATCH] lab07 #93 --- .../net1314080903208/NetActivity.java | 41 +++++++++++++++++++ app/src/main/res/layout/activity_net.xml | 21 ++++++++++ 2 files changed, 62 insertions(+) create mode 100644 app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903208/NetActivity.java create mode 100644 app/src/main/res/layout/activity_net.xml diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903208/NetActivity.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903208/NetActivity.java new file mode 100644 index 00000000..f69f19e2 --- /dev/null +++ b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903208/NetActivity.java @@ -0,0 +1,41 @@ +package skyward.com.testvolley; + +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.Response; +import com.android.volley.VolleyError; +import com.android.volley.toolbox.StringRequest; +import com.android.volley.toolbox.Volley; +public class NetActivity extends AppCompatActivity { + public static final String url = "https://github.com/Hackergeek/android-labs/tree/master/app/src/main/AndroidManifest.xml"; + public TextView tv_data; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_net); + tv_data = (TextView) findViewById(R.id.tv_data); + } + + public void getData(View view) { + RequestQueue queue = Volley.newRequestQueue(this); + StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener() { + @Override + public void onResponse(String s) { + tv_data.setText(s); + + } + }, new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError volleyError) { + + } + }); + queue.add(stringRequest); + } +} diff --git a/app/src/main/res/layout/activity_net.xml b/app/src/main/res/layout/activity_net.xml new file mode 100644 index 00000000..91e6e2ea --- /dev/null +++ b/app/src/main/res/layout/activity_net.xml @@ -0,0 +1,21 @@ + + + +