RecyclerView.ViewHolder imageViewDrawerIcon;
public void childOFrecyclerView(){
int childCount = myRecyclerView.getChildCount();
Log.d("Countttt","Count"+childCount);
myRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
for(int i=0;i<=childCount;i++)
imageViewDrawerIcon = myRecyclerView.findViewHolderForAdapterPosition(i);
if(imageViewDrawerIcon.itemView instanceof MyView){
imageViewDrawerIcon.itemView.findViewById(R.id.my_imageview).setVisibility(View.GONE);
}
}
});
}
我在Recycler视图中有10个项目视图。我必须访问id为的imageview
my_imageview
,但我得到了:
android.view.View android.support.v7.widget.RecyclerView $ ViewHolder.itemView'上为null 对象引用
请建议如何从Android的Recycler视图获取ItemView图像视图。