Skip to content

Commit

Permalink
lab07 #93
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackergeek committed May 12, 2016
1 parent 4f61309 commit ea1cee5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<String>() {
@Override
public void onResponse(String s) {
tv_data.setText(s);

}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {

}
});
queue.add(stringRequest);
}
}
21 changes: 21 additions & 0 deletions app/src/main/res/layout/activity_net.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:onClick="getData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Data"/>

<TextView
android:id="@+id/tv_data"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>

0 comments on commit ea1cee5

Please sign in to comment.