Help with a click effect for my own custom button.

by Bure » Tue, 15 Jun 2010 15:49:00 GMT


Sponsored Links
 Hi all.
Have a problem when i try to invoke a click effect for my custom
button. Basically I want my "button" to change background color for
like 100 ms and then change back to the original color. I'm using a
OnClickListener for this, with an additional thread for the sleep
effect.

The problem is that the "button" just updates the second color
(original color) and not the "click" color. I'm new to this so pls
take it easy on me :)

public class NoteButtonListener implements OnClickListener {
         public void onClick(final View v) {
                if(v instanceof NoteButton){
                                Thread t = new Thread(){
                                        public void run(){
                                                try {
                                                        
v.setBackgroundColor(Color.GREEN); //Never shown?
                                                        v.invalidate();
                                                        sleep(100);
                                                        
v.setBackgroundColor(Color.BLUE);
                                                        v.invalidate();
                                                } catch (InterruptedException 
e) {
                                                        e.printStackTrace();
                                                }

                                        }

                                };
                                t.run();
                }
                else if(v instanceof Button){
                }
         }
}

--



Other Threads

1. how to switch windows like browsers?

hi all,

i want to do the function of switch windows,
like the browsers do now,
eg:
when i open a web1 and web2,i can use the "Window" function in the
"menu" button,

how can i do??

thank you!!!
--~--~---------~--~----~------------~-------~--~----~

2. How to play video file in android.

Hi,

I am new to Android.
I have depeloped a video player app. through Sd card.

Now i want to play video direct from URL.

Can anybody provide me sample code for the same.

Thanks in advance...


Thanks
Priya

--~--~---------~--~----~------------~-------~--~----~

3. RTSP and RTP streaming on the Cupcake-upgraded

4. ListView app dies

5. How to get the audios' _id list from db

6. ListView soft input search

7. another AppWidget issue: can't start parent app, "process is bad"