views:

22

answers:

1

i want to assign an image to one of the buttons in my activity??

how do i do that?? and for that where shall i place image.jpeg or any othr image file??

A: 

Use ImageButton. Put your image in resources, and use it like this:

 <?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
     <item android:state_pressed="true"
           android:drawable="@drawable/button_pressed" /> <!-- pressed -->
     <item android:state_focused="true"
           android:drawable="@drawable/button_focused" /> <!-- focused -->
     <item android:drawable="@drawable/button_normal" /> <!-- default -->
 </selector>
Orsol