help on graphics from newbie

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


Sponsored Links
 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.

--



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;

                                mUIHandler.sendMessage(msg);

Hope that helps,
Matt




--


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

Thanks for your feedback.





>



help on graphics from newbie

by SoftwareForMe.com SoftwareForMe.com » 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. how to include eclipse

hi

every one , i am very e{*filter*}d to learn development related to android
i am totally new about it .actually i am using easyeclipse-mobile-
java-1.2.2.2.exe for j2me application develpment but in android
develment shows some eclipse europe version so aonly plz tell me we
develop android application on easyeclipse-mobile-java-1.2.2.2.exe or
not.if yes then how?

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

2. how do I close a dialog box?

I have the following code that works fine to display a dialog box
using an xml layout file.

<code>
dialog = new Dialog(this);
dialog.setContentView(R.layout.settings);

dialog.show();
</code>


How do i add event listeners to the button widgets that i placed in
the xml layout?
Is there a default button or event rather that is used to close dialog
boxes in android applications?




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

3. beat generator

4. problem about ddms

5. sharing permission

6. How can we change image after a specific interval of time.

7. Apps from SD card (no not another can it be done thread)..