Thursday, June 10, 2010

[android-developers] how can we set the background of button with bitmap image........which is cre

--> for bitmap image..this code is not working

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button bt1= (Button) findViewById(R.id.idd1);
Bitmap bitmap =
BitmapFactory.decodeStream(getResources().openRawResource(R.drawable.image1));
Bitmap Bitmap1;
Bitmap1= Bitmap.createBitmap(bitmap, 0,0 ,100,100);
bt1.setImageBitmap(Bitmap1);

}
}


--> for simple image: this is working

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button bt1= (Button) findViewById(R.id.idd1);
bt1.setBackgroundResource(R.drawable.image1);

}
}

the first one code is not working please help me out........

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment