數據變化自動通知ViewPager的適配器:Android AutoNotifyViewPager
Android AutoNotifyViewPager這個項目是ViewPager的升級版。當內容被改變時,會自動通知viewpager的適配器。
- By default ViewPager's
adapter
should be notified using mAdapter.notifyDataSetChanged() if data get's changed after setting adapter to avoid IllegalStateException - It get's difficult to update your adapter when
PagerAdapter
is in other class, typically different *.java - Example :
- In this app,
ListView's adapter
&ViewPager's adapter
share's same content. - When scrolled down to bottom of the page in ListView,
GetMoreData
is triggered, fetched, parsed & updated to ListView's adapter. - Seems easy, but when the user clicks & navigates to
ViewPager
after triggered and before updated, you end up inIllegalStateException
as the data got changed but not notified. - This can be avoided having complex
eventListeners
, instead simply use AutoNotifyViewPager
</ul>
</li>
</ul>
- In this app,
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!