help on graphics from newbie

by social hub » Sat, 27 Feb 2010 01:06:07 GMT

Sponsored Links

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

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.


help on graphics from newbie

by Gaunt Face » Sat, 27 Feb 2010 05:17:17 GMT

 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;


Hope that helps,


Sponsored Links

help on graphics from newbie

by social hub » Sat, 27 Feb 2010 05:26:23 GMT

 in this case I am doing inside a surfaceview does the same apply even for

Thanks for your feedback.


help on graphics from newbie

by » Sat, 27 Feb 2010 05:58:18 GMT

 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).


Other Threads

1. Question about Android Tablet

Hi, I'm going to develop an Android device which is not a phone, could
be Tablet or Portable Game Player.

The device will has the external input devices such as keyboard, mouse
or joystick.

Here is my question.

Does Android provides an API for handling that kind of external input
devices, or should I design and implement APIs for them?


2. Samsung Galaxy, GPS onLocationChanged never called.


Anyone reported a bug with Samsung Galaxy (Android 1.5) ? It seems the
onLocationChanged  method never get called.

All my listener receive is call to

I tested it on HTC magic, I can see a few called to onStatusChanged
with TEMPORARILY_UNAVAILABLE but eventually the GPS retrieves a
location and calls onLocationChanged but I doesn't seem to happen on
Galaxy, even after waiting a few minutes.

Google Maps is able to retrieve the position and display it on the
Samsung Galaxy but I am unsure it is using the same method I do.


3. Can we bind one object on surface of another in openGL ES??

4. How long Service#onDestroy is allowed to run ?

5. Google sync removes third party calendars

6. Ask about gmail apps