- 論壇徽章:
- 0
|
本帖最后由 kingink1983 于 2010-06-19 00:31 編輯
在參照android docs學(xué)習(xí)的過(guò)程,發(fā)現(xiàn)/tutorials/hello-world.html界面下的【Upgrade the UI to an XML Layout】節(jié)的例子在前面的基礎(chǔ)上無(wú)法編過(guò)
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"/>
復(fù)制代碼
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>
復(fù)制代碼
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);
- }
- }
復(fù)制代碼
僅僅是更新里textview的調(diào)用方式,在工程中,src和res的文件夾中均顯示錯(cuò)誤,無(wú)法編譯,
教程中尚無(wú)特別的提示,還望大家給予指點(diǎn)。謝謝。 |
|