0
我有一個ListView擴展BaseAdapter。我想調用notifyDataSetChanged()方法來刷新IntentService中的列表視圖!無論如何要這樣做?Android通知ListView BaseAdapter從IntentService
我有一個ListView擴展BaseAdapter。我想調用notifyDataSetChanged()方法來刷新IntentService中的列表視圖!無論如何要這樣做?Android通知ListView BaseAdapter從IntentService
是的,你可以註冊一個LocalBroadcastReceiver
您Activity
或Fragment
(或者甚至在你Adapter
雖然我不會推薦)和更新您的List
上Broadcast
接收。以實例和代碼段詳細說明在這裏:
https://developer.android.com/training/run-background-service/report-status.html
P.S:雖然我真的建議使用AsyncTask
如果你的操作是關係到View
該用戶是交互用。 IntentService
通常用於需要運行存在的操作,即使在銷燬View
後仍能正常工作。
使用localBrodcast MAnager –
感謝但如果我有3個listviews並刷新它基於用戶可見的列表視圖! –
是你在同一活動中的列表視圖嗎? –