HttpURLConnection和HttpClient都可以访问网络,前者是Java的标准类,后者是Apache的一个开源项目,两者使用起来效果一样,但后者更为简单。
以下是针对前者完成的一个实例:
首先写好布局文件:
<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=m