android - 外部获取RecyclerView中viewholder持有的控件
ringa_lee
ringa_lee 2017-04-17 17:58:47
0
1
634

使用

CrimeHolder holder1 = (CrimeHolder) mCrimeRecyclerView.findViewHolderForAdapterPosition(1);

然后使用holder1.getxxxx();

但是我在外部调用时提示
·······getTitleTextView()' on a null object reference,调试发现holder1为null,求解决方案

调用时机:Fragment的onResume()方法中。

ringa_lee
ringa_lee

ringa_lee

reply all(1)
左手右手慢动作

Not sure, it’s best to add more code
If it involves related logic after the view layer is created, it’s best to execute it in view.post.

view.post(new Runnable(){
//这里在view加载完毕之后将得到执行

})
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template