place a bitmap as background of a view
<p>I have a view. I want to place a bitmap image as its background image. I was not able to do that.</p>

<pre><code>//My code is below

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.grape);
part1 = new View(this); 
Bitmap map2 = Bitmap.createBitmap(targetWidth, targetHeight,Bitmap.Config.ARGB_8888);
canvas.drawBitmap( bitmapOrg,new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), new Rect(0, 0, targetWidth, targetHeight), null);

part1.setBackgroundResource(map2); //i couldn't place map2 as bgresource to my view part1
</code></pre>

<p>can anyone help?</p>
