-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f61309
commit ea1cee5
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
app/src/main/java/edu/hzuapps/androidworks/homeworks/net1314080903208/NetActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |