Skip to content

Instantly share code, notes, and snippets.

@sudhanshuraheja
Created March 7, 2014 07:10
Show Gist options
  • Save sudhanshuraheja/9406766 to your computer and use it in GitHub Desktop.
Save sudhanshuraheja/9406766 to your computer and use it in GitHub Desktop.
@Override
public View getView(int position, View convertView, ViewGroup paramViewGroup) {
Object current_event = mObjects.get(position);
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.row_event, null);
holder.ThreeDimension = (ImageView) convertView.findViewById(R.id.ThreeDim);
holder.EventPoster = (ImageView) convertView.findViewById(R.id.EventPoster);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
// If you have conditions like below then you may face problem
if (doesSomeComplexChecking()) {
holder.ThreeDimention.setVisibility(View.VISIBLE);
} else {
holder.ThreeDimention.setVisibility(View.GONE);
}
// This method is setting layout parameters each time when getView is getting called which is wrong.
RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(measuredwidth, rowHeight);
holder.EventPoster.setLayoutParams(imageParams);
return convertView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment