- 论坛徽章:
- 0
|
本帖最后由 kingink1983 于 2010-06-19 00:31 编辑
在参照android docs学习的过程,发现/tutorials/hello-world.html界面下的【Upgrade the UI to an XML Layout】节的例子在前面的基础上无法编过
1 In the Eclipse Package Explorer, expand the /res/layout/ folder and open main.xml (once opened, you might need to click the "main.xml" tab at the bottom of the window to see the XML source). Replace the contents with the following XML:
- <?xml version="1.0" encoding="utf-8"?>
- <TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@id+/textview"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:text="@string/hello"/>
复制代码
Save the file.
2.# Inside the res/values/ folder, open strings.xml. This is where you should save all default text strings for your user interface. If you're using Eclipse, then ADT will have started you with two strings, hello and app_name. Revise hello to something else. Perhaps "Hello, Android! I am a string resource!" The entire file should now look like this:
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <string name="hello">Hello, Android! I am a string resource!</string>
- <string name="app_name">Hello, Android</string>
- </resources>
复制代码
3 Now open and modify your HelloAndroid class use the XML layout. Edit the file to look like this:
- package com.example.helloandroid;
- import android.app.Activity;
- import android.os.Bundle;
- public class HelloAndroid extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
- }
复制代码
仅仅是更新里textview的调用方式,在工程中,src和res的文件夹中均显示错误,无法编译,
教程中尚无特别的提示,还望大家给予指点。谢谢。 |
|