1、String[] moduleArray = getResources().getStringArray(R.array.main_gridView);
獲取string.xml中String-array
<string-array name="main_gridView">
<item>我是1</item>
<item>我是2</item>
<item>我是3</item>
<item>我是4</item>
<item>我是5</item>
<item>我是6</item>
</string-array>
2、list集合和堆棧管理Activity的區別
3、JSON中optString和getString的區別
optString方法會在對應的key中的值不存在的時候返回一個空字符串或者返回你指定的默認值,但是getString方法會出現空指針異常的錯誤。
4、JSON解析之 getJSONObject 與 optJSONObject 的區別
//optJSONObject源碼解析:
/**
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONObject}. Returns null otherwise.
*/
public JSONObject optJSONObject(String name) {
Object object = opt(name);
return object instanceof JSONObject ? (JSONObject) object : null;
}
//當返回值不是JSONObject對象時,返回值爲null,不拋出異常;
//getJSONObject源碼解析:
/**
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONObject}.
* @throws JSONException if the mapping doesn't exist or is not a {@code
* JSONObject}.
*/
public JSONObject getJSONObject(String name) throws JSONException {
Object object = get(name);
if (object instanceof JSONObject) {
return (JSONObject) object;
} else {
throw JSON.typeMismatch(name, object, "JSONObject");
}
}
//當返回值不是JSONObject對象時,拋出異常;
5、android:completionThreshold="1"
屬性設置了一個閥值,規定用戶打了多少字符之後纔出現自動提示,默認值是2,我們在這裏改成了1。
6、MultiStateView
MultiStateView實現容器狀態切換(容器內容,加載狀態,錯誤狀態,空狀態)
Content 、Loading、Error、Empty
mMultiStateView = (MultiStateView) findViewById(R.id.multiStateView);
mMultiStateView.getView(MultiStateView.ViewState.ERROR).setOnClickListener(layoutClick);
mMultiStateView.getView(MultiStateView.ViewState.EMPTY).setOnClickListener(layoutClick);