Android开发之获取web服务器xml数据
Android开发之获取web服务器xml数据
Android开发之获取web服务器xml数据
首先我们需要配置J2EE开发环境,并部署web应用viderweb,启动服务
然后开始我们的程序代码
我们的程序大致是获取web服务器xmlàpull解析xmlàListView列表显示数据
添加业务bean类Video
- package cn.class3g.domain;
- public class Video {
- private int id;
- private String title;
- private int timeLenght;
- public Video() {
- super();
- // TODO Auto-generated constructor stub
- }
- public Video(int id, String title, int timeLenght) {
- super();
- this.id = id;
- this.title = title;
- this.timeLenght = timeLenght;
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public int getTimeLenght() {
- return timeLenght;
- }
- public void setTimeLenght(int timeLenght) {
- this.timeLenght = timeLenght;
- }
- @Override
- public String toString() {
- return "Video [id=" + id + ", title=" + title + ", timeLenght="
- + timeLenght + "]";
- }
- }
布局
- main.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <ListView
- android:id="@+id/listViewID"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
- </ListView>
- </LinearLayout>
Item.xml
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal" >
- <TextView
- android:id="@+id/titleID"
- android:layout_width="200dp"
- android:layout_height="wrap_content" />
- <TextView
- android:id="@+id/timelengthID"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
- </LinearLayout>
|
评论暂时关闭