change colors in an AnalogClock

by Simone » Sat, 03 Apr 2010 00:43:26 GMT


Sponsored Links
 Hi, I was wondering if it was possible to change the color of the
minute and hour hands of an AnalogClock.
Thanks
Simone

--



Other Threads

1. Working on a Mobile or Embedded Device/System? Tell VDC about your experiences for a chance to WIN!

VDC is conducting its annual survey of mobile and embedded engineers
so if you are involved in the engineering of mobile or embedded
systems/software, this is your chance to influence key solution
suppliers.

The research covers embedded software, hardware, tools, and
development practices. Your thoughts will improve our insights into
the engineering community and help to influence next generation
solutions.

In addition, VDC will provide all respondents who complete the
survey:

* Instant access to a summary of VDC's 2009 survey findings;
* Entry into a prize drawing for one of five $100 Amazon.com gift
certificates (drawing to be held August 15th, 2010); and
* A summary of the 2010 survey findings once the survey is complete
later this year


To begin the survey, go to: http://bit.ly/a4cgtb


Thank you very much for your assistance.


Best Regards,

The VDC Embedded Software and Tools Research Team

-- 

2. Handler: UI gets updated all at once at the end

I'm using AudioRecord in a separate class, and I have it read a buffer
in a loop and callback to the main activity with the buffer.

The activity processes the buffer and calculates a number that I want
to update the UI with (I'm using animation to move a button).  What
I'm finding is that first all the buffers are getting processed, and
then after that's done, the handler is apparently handling all the
messages and doing all the UI updates one after the other.

Perhaps this is working as designed because I think the handler
message processing occurs after the other work is done.  If this is
true, what can I do to process a buffer and then immediately update
the UI (and do that for each buffer)?

Here's a snippet of the recording part.  In the constructor, I'm
passing in a reference to the activity so I can callback to it.

        Recorder(myActivity act)
        {
                super();
                this.setFrequency(frequency);
                this.setChannelConfiguration(AudioFormat.CHANNEL_IN_MONO);
                this.setPaused(false);
                this.act = act;
        }

                AudioRecord recordInstance = new AudioRecord(
                                MediaRecorder.AudioSource.MIC,
                                this.getFrequency(),
                                this.getChannelConfiguration(),
                                this.getAudioEncoding(),
                                bufferSize);

                recordInstance.startRecording();

                buffer = new byte[bufferSize];

                while (this.isRecording) {
                        // Are we paused?
                                        synchronized(mutex)
                                        {
                                        if (this.isPaused)
                                                {
                                                        try
                                                        {
                                                                mutex.wait(250);
                                                        }
                                                        catch 
(InterruptedException e)
                                                        {
                                                                throw new 
IllegalStateException("Wait() interrupted!",e);
                                                        }
                                                        continue;
                                                }
                                        }

                                        bufferRead = 
recordInstance.read(buffer, 0, bufferSize);

                                        if (bufferRead == 
AudioRecord.ERROR_INVALID_OPERATION)
                                        {
                                                throw new 
IllegalStateException("read() returned
AudioRecord.ERROR_INVALID_OPERATION");
                                        }
                                        else if (bufferRead == 
AudioRecord.ERROR_BAD_VALUE)
                                        {
                                                throw new 
IllegalStateException("read() returned
AudioRecord.ERROR_BAD_VALUE");
                                        }
                                        else if (bufferRead == 
AudioRecord.ERROR_INVALID_OPERATION)
                                        {
                                                throw new 
IllegalStateException("read() returned
AudioRecord.ERROR_INVALID_OPERATION");
                                        }

                                        // Write buffer to file
                                        try
                                        {
                                                fWriter.write(buffer);
                                        }
                                        catch (Exception e)
                                        {
                                                Log.d(Recorder.class.getName(), 
e.getMessage());
                                        }

                                        payloadSize += buffer.length;

                                        // Tell activity we have a buffer to 
process
                                        act.startLongRunningOperation();
        }

Here's what I have in the activity (I instantiate Recorder in
onCreate()):

    // Need handler for callbacks to the UI thread
    final Handler mHandler = new Handler();

    // Create runnable for posting
    final Runnable mUpdateResults = new Runnable() {
        public void run() {
            updateResultsInUi();
        }
    };

   protected void startLongRunningOperation()
    {
     // Fire off a thread to do some work that we shouldn't do
directly in the UI thread
        Thread t = new Thread() {
            public void run() {
                mHandler.postAtFrontOfQueue(mUpdateResults);
            }
        };
        t.start();
    }

    private void updateResultsInUi()
    {
        // Back in the UI thread -- update our UI elements based on the
data in mResults
        animateButton();
    }

-- 

3. AutoCompleteTextView not working?

4. NewsRob 3.9 Beta

5. Is it possible to set up a boot password

6. setOnClickListener doesnt work after a call to startActivity()...

7. setOnClickListener doesnt work after a call to startActivity()...