-
如果能搜到我這篇文章都應該是知道VirtualLayout這個東西的,這是Alibaba開發的一個LayoutManager,主要是對于RecyclerView的擴展,想當年我還是很苦逼的處理各式各樣的viewtype,簡直是一段艱辛的歲月,自從有了這個之后就感覺到解放一樣,好了,廢話不多說,這里主要是記述一個第一次使用過程中的錯誤:
java.lang.IllegalStateException: Cannot change whether this adapter has stable IDs while the adapter has registered observers.
-
解決方法如下:
一定要使用List容器裝好Adapter再用setAdapters()方法設置進去,否則報錯,至于原因,再看了源碼以后是RecyclerView的原因//一定要使用List容器裝好Adapter再用setAdapters()方法設置進去,否則報錯 List<DelegateAdapter.Adapter> adapters = new ArrayList<>(); CommonAdapter adapter1 = new CommonAdapter(this, new LinearLayoutHelper(), R.layout.item, list) { @Override public void convert(ViewHolder holder, Object o, int position) { holder.setText(R.id.text01, position + ""); } }; adapters.add(adapter1); CommonAdapter adapter2 = new CommonAdapter(this, new GridLayoutHelper(3), R.layout.item, list) { @Override public void convert(ViewHolder holder, Object o, int position) { holder.setText(R.id.text01, position + ""); } }; adapters.add(adapter2); adapter.setAdapters(adapters);
VirtualLayout:Cannot change whether this adapter has stable IDs while the adapter has registered observers.
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
推薦閱讀更多精彩內容
- 初識Android時,我對ListView、GradView中的Adapter一直半懂非懂,每次寫Adapter都...
- made Fast and Easy字數2326 閱讀79 評論0 喜歡1Fastadapter使Recycler...