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. GridView is not coming in center of parent

I am using following to display gridview of images :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"

android:id="@+id/widget28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

<GridView
android:id="@+id/widget29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
</GridView>
</RelativeLayout>

But it is giving display left side with center_ vertical,

I used android:layout_centerHorizontal="true" also to bring grid view
in to horizantal center , then also it is giving left side of parent
with center_ vertical,

   I want to display grid view in center(vertical as wel as hori in
parent OR if this not possible then Cente_hori);
   I tried all but for any options but it either gives top_left  of
parent or
either left_with_vertical_center.

Whats the matter will some body clear me.

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

2. Fwd: Working of locationListener() in real time on device?

Kindly look into this query........

Thanks.....

---------- Forwarded message ----------
From: sheik <sheik...@gmail.com>
Date: Feb 12, 3:05pm
Subject: Working of locationListener() in real time on device?
To: Android Developers


Hi,
i need to know about the LocationListener() working in therealtime...

Does it expect the user(device) to move in order to update the
current location details or it automatically updates when ever the gps
is enabled?

Another query is regarding the getLastKnownLocation().....

When is that last known location will be lost and thus returns null...
(in realtime)...

Thanks,
regards,
sheik

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

3. Android Conference in Bangalore

4. Problem in going in back/previous activity

5. Android Screen Size Question

6. How to cancel a notification?

7. How to get uncompressed sound(uncompressed MP3) data in Android framework