1

In my application i have one black and white image, now to want to change the black and white image into colored image like where ever i click on that image only that portion become colored

Thanks

Monali
  • 1,966
  • 12
  • 39
  • 59
  • 3
    There are so many ways this can be done, you've given no context as to how you want to do it. Is it a bitmap image on a canvas? Is it an ImageView etc. Try to put as much information as you can in your questions, you'll get replies that are more helpful. – C0deAttack Jan 21 '11 at 11:05

2 Answers2

2

try this take two different images one is normal image another one is focus image

main.xml code:

<ImageView 
                     android:id="@+id/emailsendimage" 
                     android:layout_height="wrap_content"
                     android:layout_width="wrap_content"
                     android:clickable="true"
                     android:focusable="true"                   
                     android:src="@drawable/sendchat_normal_icon" />

next codefile:

 Submit.setOnFocusChangeListener(new OnFocusChangeListener() {

                    public void onFocusChange(View v, boolean hasFocus) {
                        // TODO Auto-generated method stub
                        if(hasFocus){
                             Submit.setImageResource(R.drawable.sendchat_over_icon);
                        }else{
                             Submit.setImageResource(R.drawable.sendchat_normal_icon);
                        }
                    }
                });
Narasimha
  • 3,802
  • 11
  • 55
  • 83
0

Try using Selector for setting different images on different states.

check this and this link out

Community
  • 1
  • 1
Aman Alam
  • 11,231
  • 7
  • 46
  • 81
  • It can be used for an ImageView as well. just put inside a 'drawable' folder (nor drawable-Xdpi) and refer to it in the ImageView like – Aman Alam Jan 21 '11 at 11:20
  • Maybe, but i don't know them. At last, you can always do the things with code. – Aman Alam Jan 21 '11 at 11:29