Android应用开发之获取web服务器xml数据

public class MyVideoNewsActivity extends Activity {           public void onCreate(Bundle savedInstanceState) {           super.onCreate(savedInstanceState);           setContentView(R.layout.main);                     try {              List<Video> videos = VideoService.getLastVideos();//获取最新视频资讯              ListView listView = (ListView)this.findViewById(R.id.listView);              List<HashMap<String, Object>> data = new ArrayList<HashMap<String,Object>>();              for(Video video : videos){                 HashMap<String, Object> item = new HashMap<String, Object>();                 item.put("title", video.getTitle());                 item.put("timelength", "时长:"+video.getTimelength());                 item.put("id", video.getId());                 data.add(item);              }              SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.item,                     new String[]{"title","timelength"}, new int[]{R.id.title, R.id.timelength});              listView.setAdapter(adapter);          } catch (Throwable e) {              Log.e("TAG", e.toString());              Toast.makeText(this, R.string.error, 1).show();          }          }   }  

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyjpgy.html