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);