Yes. This is perfect for use in the Surface view.

The first code snippet can go anyplace. The relayout call should go where
the // Do Stuff Here comment is.

The second bit should go where you want to call relayout at (but can't
because it's in the background thread).

On Fri, Feb 26, 2010 at 1:26 PM, social hub <[email protected]> wrote:

> in this case I am doing inside a surfaceview does the same apply even for
> surfaceview.
>
> Thanks for your feedback.
>
>
> On Fri, Feb 26, 2010 at 3:17 PM, Gaunt Face 
> <[email protected]>wrote:
>
>> What I think you need to do is set up a Handler between the main
>> activity and your background thread('s).
>>
>> Basically a Handler is a way to communicate between the main UI thread
>> and background threads, this way anything that must be done on the UI
>> event can be achieved by sending a message from the background thread
>> through the handler, you then override the handleMessage function in
>> the Handler and your good to go:
>>
>>    mUIHandler = new Handler() {
>>
>>                public void handleMessage(Message msg)
>>                {
>>                        if(msg.arg1 == SOME_CONSTANT)
>>                        {
>>                                       // Do Stuff Here
>>                        }
>>                }
>>
>>        };
>>
>>
>> Then in your background thread you'd do something like:
>>
>>                                Message msg = Message.obtain();
>>                                msg.arg1 = SOME_CONSTANT;
>>
>>                                mUIHandler.sendMessage(msg);
>>
>> Hope that helps,
>> Matt
>>
>> On Feb 26, 5:05 pm, social hub <[email protected]> wrote:
>> > Guys,
>> >
>> > I almost there of what i want to do but i am stuck at a point where I
>> need
>> > some expert pointers
>> >
>> > this is what i do so far
>> >
>> > I have rectangle white box
>> >
>> > on cliking the rectangle I will draw a toolbar beneath the box and also
>> call
>> > relayout to accomodate the toolbar ( size+100) ( i used surfaceview and
>> in
>> > secondary thread i draw the toolbar)
>> >
>> > on click again on rectangle box it will disappear the toolbar and also
>> has
>> > to resize the layout to original size (ie size-100) this is where I get
>> > stuck.
>> >
>> > I can disappear the toolbar however I cant call relayout either from
>> > secondary thread (says cant call from secondary thread).
>> >
>> > So I created a while loop in onlayout( this is where i create a thread
>> to
>> > draw the toolbar)  if i call requestlayout after while loop ends it
>> doesnt
>> > do anything it doesnt call onmeasure etc.
>> >
>> > Please help me where I am doing wrong.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]<android-developers%[email protected]>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

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

Reply via email to