- 錯誤:
android - Binary XML file line #2: Error inflating class <unknown>
- 原因:是bitmap圖片過大,或xml書寫有誤(如selector定義出錯)
Dagger2中如果@Inject注解的構造函數非public將不會被納入Dagger控制的類
-
Observable.concat(A, B)
當A為hot observable時會忽略后續所有的observable,應注意。文檔原文如下:
Concat waits to subscribe to each additional Observable that you pass to it until the previous Observable completes. Note that because of this, if you try to concatenate a “hot” Observable, that is, one that begins emitting items immediately and before it is subscribed to, Concat will not see, and therefore will not emit, any items that Observable emits before all previous Observables complete and Concat subscribes to the “hot” Observable.
解決辦法:
Observable.concat(hotObservable.first(), coldObservable).subscribe();
其中,first()
方法能夠時hot observable轉變為cold observable,一個single。realm中設置primary key要小心,比如記錄不同周次的object, 該object中的成員最好也按照(唯一名稱+周次).hashcode()作為唯一id的primary key; 同時數據庫版本升級要migration。
- 當rxjava中需要skip流中發生的error時可使用
onErrorResumeNext(Observable.empty())
,防止concat(dataFromStore, dataFromServer)
時流中出錯導致中斷。
- The task can be executed only once (an exception will be thrown if a second execution is attempted.)
- AsyncTask只能
execute()
一次,cancel()
不能restart。
- List用iterator可以放心remove()
- 要使得ListView,RecyclerView有ScrollView的效果。
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
- Throwable是Error和Exception及其子類的超類,用Throwable作為異常或錯誤拋出。因此用instanceof分辨自定義異常或錯誤時要調用Throwable.getCause()。