Android客户端对服务端返回的xml文件内容进行解析
一、首先得到服务器端的xml文件
public class ListViewActivity extends Activity {private ListView list;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.listtext);list = (ListView)this.findViewById(R.id.list);try {List<Video> videolist = GetVideoService.getVideoList();System.out.println("--------------"+videolist);List<Map<String,String>> listItems = new ArrayList<Map<String,String>>();for(Video video : videolist) {Map<String,String> listItem = new HashMap<String, String>();listItem.put("name", video.getName());listItem.put("time", video.getTime());listItems.add(listItem);}SimpleAdapter adapter = new SimpleAdapter(Ku6Activity.this, listItems, R.layout.ku6, new String[]{"name","time"}, new int[]{R.id.name,R.id.time});list.setAdapter(adapter);} catch (Exception e) {Toast.makeText(Ku6Activity.this, "网络连接失败", Toast.LENGTH_SHORT).show();e.printStackTrace();}}}
??
1 楼 zhjpmomo 2012-04-26 楼主能不能发个源码项目啊,有点乱啊。