01
02
03
04
05
06
07
08
09
10
11
12
|
URL url = newURL(“[url]http:
//192.168.50.50:8080/Mp3Site/music/musics.xml[/url]");
conn = url.openConnection();
is_sdcard = conn.getInputStream();
File destFile = newFile(
"/sdcard/musics.xml"
);
destFile.createNewFile();
String path = destFile.getAbsolutePath();
FileOutputStream fos_sdcard = newFileOutputStream(destFile);
int
bytesRead;
byte
buff[] = newbyte[
1024
];
while
((bytesRead = is_sdcard.read(buff))>
0
) {
fos_sdcard.write(buff,
0
, bytesRead);
}
fos_sdcard.close(); is_sdcard.close();
|
01
02
03
04
05
06
07
08
09
10
11
|
/* 将XML转换成Document对象 */
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db =dbf.newDocumentBuilder();
Document doc = db.parse(is);
NodeList nodeList =doc.getElementsByTagName(elementsTagName);
int
len = nodeList.getLength();
for
(
int
i =
0
; i < len; i++) {
Stringcontent = nodeList.item(i).getChildNodes().item(
0
)
.getNodeValue();
list.add(content);
}
|
1
2
3
|
mTabHost.addTab(mTabHost.newTabSpec(
"tab_test1"
)
.setIndicator(
"TAB1"
,getResources().getDrawable(R.drawable.img1))
.setContent(newIntent(
this
,OtherActivity.
class
)));
|