Android grid view recycle issue
===

I get an error when i try to use the a recycled gridview every time if convertView != null then i get an error here is my source code.

$ 	public View getView(int position, View convertView, ViewGroup parent) {

		RelativeLayout lay;
	
		ImageView image;
		TextView text;
		if (convertView == null) {
			Log.d("height", "Width = " + width);

			lay = new RelativeLayout(mContext);
			image = new ImageView(mContext);
			text = new TextView(mContext);
		

			//text.setText("This is a test");
			text.setTextSize(14);
			text.setTextColor(Color.WHITE);
			text.setGravity(Gravity.LEFT | Gravity.TOP);
			text.setPadding(2, 2, 2, 2);
			text.setBackgroundColor(Color.parseColor("#80000000"));
			RelativeLayout.LayoutParams textLayout = new RelativeLayout.LayoutParams(
					(int) Math.round(width / 2.0),
					(int) Math.round(width / 8.3));

			textLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
			text.setLayoutParams(textLayout);

			MarginLayoutParams textMarginFix = (ViewGroup.MarginLayoutParams) text
					.getLayoutParams();
			textMarginFix.setMargins(0, 0, 0, (int) Math.round(width / 45.0));
			text.setLayoutParams(textMarginFix);

			image.setLayoutParams(new LayoutParams((int) Math
					.round(width / 2.0), (int) Math.round(width /              2.0)));
		
			image.setScaleType(ImageView.ScaleType.CENTER_CROP);
			//image.setImageResource(mThumbIds[position]);
			
			lay.setLayoutParams(new GridView.LayoutParams((int) Math
					.round(width / 2.0), (int) Math.round(width / 2.0)));
			lay.setBackgroundResource(R.drawable.shadowimage);
			lay.setPadding(5, 5, 15, 15);
			//lay.setId(mThumbIds[position]);

			//lay.addView(image);
			//lay.addView(text);

		} 
		else
		{
			text = (TextView) convertView;
			image = (ImageView) convertView;
			lay = (RelativeLayout) convertView;
		}

		image.setImageResource(mThumbIds[position]);
		text.setText("This is a test");
		 
		lay.addView(image);
	    lay.addView(text);
		
		 return lay;

	}