Google Android之运用XML布局
package
org.andylee1988;
import
android.app.Activity;
import
android.os.Bundle;
public
class
HelloAndylee1988
extends
Activity {
/**
Called
when
the
activity
is
first
created.
*/
@Override
public
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.
main
);
}
}
编辑main.xml,输入以下代码:
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
TextView
xmlns:android
=
"http://schemas.android.com/apk/res/android"
android:layout_width
=
"fill_parent"
android:layout_height
=
"fill_parent"
android:text
=
"@string/hello"
/>
编辑strings.xml,输入:
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
resources
>
<
string
name
=
"hello"
>
Hello, andylee1988! I am a string resource!
</
string
>
<
string
name
=
"app_name"
>
Andylee1988
</
string
>
</
resources
>
运行后将看到: