01、 Liner Layout
一維順序排列02、 Relative Layout
相對佈局03、 Frame Layout
04、 Table Layout
05、 Activity 生命周期

06、 在AndroidManifest.xml中註冊Activity元件
07、 Intent Bundle
Intent intent = new Intent();
intent.setClass(this,Report.class);
Bundle bundle = new Bundle();
bundle.putString("name","peterpai");
intent.putExtras(bundle);
startActivity(intent);
Bundle bundle = this.getIntent().getExtras();
String name = bundle.getString("name");
08、新增一個Activity的流程
1、定義一個Activity的子類別2、定義對應的XML版面配置
3、覆寫Activity中的onCreate(),處理XML版面配置和Intent的傳值
4、將元件註冊進AndroidManifest.xml
09、Log
private final String TAG = "MainActivity";// Log.i(TAG, "bala bala....");
10、Toast
Toast toast = Toast.makeText(this,"Hello Toast!!",Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP|Gravity.RIGHT,0,0); toast.show();
11、資源檔、字串、多語系
res/values/strings.xml 放置預設的文字資源res/values-zh-rCN/strings.xml 放置簡中的文字資源
strings.xml的宣告
My Note - 新年
- 中秋節
- 端年節
- 今年有一天假日
- 今年有%d天假日
java中的引用法
String appName = getResources().getString(R.string.app_name);//取字串 Resources res = getResource(); String[] holidays = res.getStringArray(R.array.holidays);//取字串陣列 String holidayComment = res.getQuantityString(R.plurals.holiday_summary,holidays.length);//處理複數字串
XML中的引用法
@string/app_name
12、SharedPreferences
13、AlertDialog
// create a new AlertDialog Builder
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.welcome_message_title);
builder.setMessage(R.string.welcome_message);
builder.setPositiveButton(R.string.button_ok, null);
builder.show();
沒有留言:
張貼留言