标签:
1.android逻辑和视图分离
在布局文件中编写界面,在activity中引入。比如
activity中的onCreate()的setContentView()
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate(bundle) called");
setContentView(R.layout.activity_main);
}
2.android一般把字符串定义在res/values/strings.xml中,然后可以在布局文件中引用。
首先,我们看看strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">HelloWorld</string>
<string name="edit_message">here shows questions</string>
<string name="action_settings">Settings</string>
<string name="correct">correct!</string>
<string name="title_activity_display_messgae">DisplayMessgaeActivity</string>
<string name="hello_world">Hello world!</string>
<string name="incorrect">incorrect!</string>
<string name="correct_toast">your answer is Correct!</string>
<string name="incorrect_toast">your answer is not Correct!</string>
<string name="next_question">next question</string>
<string name="question_zhoujie">zhoujie\‘s age is 22</string>
<string name="question_zhangwei">zhangwei\‘s age is 24</string>
<string name="question_majian">majian\‘s age is 26</string>
<string name="last_question">last question</string>
<string name="action_search">search</string>
</resources>
R.string.edit_message
@string/edit_message
标签:
原文地址:http://my.oschina.net/u/2275839/blog/381744