drawLayout() problem
Opened this issue · 0 comments
alirizagoksu commented
in drawLayout() method you called removeAllViews() method then add child view to cloudView; the problem is that removeAllViews() call these methods requestLayout(), invalidate()
mean refresh draw on window, cause of that if you refresh adapter user can see all view removed than added new view to cloudview and sometimes views removed but new views added can't draw. I suggest use removeAllViewsInLayout() instead removeAllViews() and called requestLayout(), invalidate() methods end of methods
private void drawLayout() {
if (mAdapter == null || mAdapter.getCount() == 0) {
return;
}
this.removeAllViewsInLayout();
for (int i = 0; i < mAdapter.getCount(); i++) {
View view = mAdapter.getView(i, null, null);
final int position = i;
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mListener != null) {
mListener.itemClick(position);
}
}
});
this.addView(view);
}
this.requestLayout();
this.invalidate();
}