作者freedom74569 (莫急莫慌莫害怕)
看板AndroidDev
标题[问题] RecyclerView 使用 notifyDataSetChanged
时间Sat Dec 26 08:41:03 2015
就是我的Arraylist是从一个library一直传过来我的APP这,
然後要放入Recyclerview中,
可是不知道怎麽放RecyclerViewAdapter.notifyDataSetChanged();,
我有把它放在一直更新资料的那个method不过那里侦测不到notifyDataSetChanged,
因为资料是在library更动的,
无法用这notifyDataSetChanged funtion
Code大概是这样:
@Override
public void bluetoothDeviceListRenewed(BluetoothList bluetoothList) {
// mdevice跟bluethoothlist是arraylist
mDevices = bluetoothList;
mRecyclerViewAdapter.notifyDataSetChanged();
}
这样会出现notifyDataSetChanged nullexception
想请教看看这个如何解呢!?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 61.230.74.188
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/AndroidDev/M.1451090467.A.79A.html
1F:→ KeySabre: 是否因为list回传时adapter还是null?如果是,那是否ada 12/26 09:32
2F:→ KeySabre: pter本来就不会那麽早初始完成? 12/26 09:32
3F:推 BearrrXD: 完整一点贴上来 12/26 11:04
4F:→ freedom74569: Key大大你後面那句有点不太能理解 12/26 11:38
5F:→ freedom74569: Bearrr 要明天晚上我再补上完整一点的 12/26 11:40
6F:推 bear0221: 试着在接受到资料的地方 印个adapter的物件状态吧 12/26 15:16
7F:→ KeySabre: 先学会logcat的使用吧 12/26 17:55
8F:→ freedom74569: 有的,我会用log先印出来,不过想说要贴上程式码, 12/26 23:20
9F:→ freedom74569: 就把log们移掉 12/26 23:20
10F:→ freedom74569: bear0221 好的,我明晚试试,因为手边没电脑 12/26 23:22