1 年,3 月
Questions & Answers
168
package com.FlickrView;
import 安卓.app.Activity;
import 安卓.os.Bundle;
import java.net.*;
import java.io.*;
public class FlickrView extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
URL flickr = new URL("http://api.flickr.com/services/feeds/photos_public.gne?id=39350419@N06&lang=en-us&format=rss_200");
URLConnection flickrConnect = flickr.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(flickrConnect.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
catch (MalformedURLException e) {
System.out.println("Unable to load URL");
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
# 1 楼答案
因为您的GUI文件中有Hello,World。看看
res/layout/main.xml
和res/values/strings.xml
。当您传入R.layout.main
(一个int)时,相应的视图将从main加载。xml,它依赖于字符串。xml# 2 楼答案
我很确定,因为您有默认的main。xml布局。在此默认布局中,LinearLayout中有一个TextView。TextViews文本设置为“Hello World,yourApplicationName”
为了显示任何内容,您必须对GUI进行一些操作
编辑:系统。出来println会将所有内容重定向到您的Android日志。您可以使用Logcat查看日志