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 reverse ListView scrolling behavior?

I have been trying now for a few hours to reverse the scrolling of
behavior of the ListView.  Essentially when scrolling down with my
finger I want the list to scroll up!  :)

Any tips?

Thanks!
-Moto

-- 

2. HttpClient routine works but w/o connection, it times out?

Hello,

This code does what I want and works just fine as long as there is
"service" or an "internet connection".

*********** code **********************
   public static String getHTTPresult(String URLwithGet){
        Log.d("MP103", TAG + "--------start
getHTTPresult--------------------------------");
        String strTemp = "this is a XX test";
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(URLwithGet);
        Log.d("MP103", TAG + "executing request " + httpget.getURI());
        ResponseHandler<String> responseHandler = new
BasicResponseHandler();
        String responseBody = "";
        Log.d("MP103", TAG + "just before try ");
                try {
                        responseBody = httpclient.execute(httpget, 
responseHandler);
                } catch (ClientProtocolException e) {
                        e.printStackTrace();
                Log.d("MP103", TAG + "error in getHTTPresult,
ClientProtocolException = " + e.toString());
                } catch (IOException e) {
                Log.d("MP103", TAG + "error in getHTTPresult, IOException = "
+ e.toString());
                        e.printStackTrace();
                } catch (Exception e) {
                        e.printStackTrace();
                Log.d("MP103", TAG + "error in getHTTPresult, Exception = " +
e.toString());
                Log.d("MP103", e.toString());
                }
        Log.d("MP103", TAG + "after try catch ");
        if (responseBody == "") {
            Log.d("MP103", TAG + "responseBody = ''");
            responseBody = "http error, responseBody = ''";
        }
        else {
            Log.d("MP103", TAG + "responseBody !== ''");
            //Log.d("MP103", TAG + responseBody);
        }
        Log.d("MP103", TAG + "--------end
getHTTPresult--------------------------------");
        httpclient.getConnectionManager().shutdown();
        return responseBody;
    }
******************* end code ****************************

My beta tester had trouble when he was out of service. His description
was "it froze up".
When I test on the emulator, I unplug the network cable, and thus have
no connection. On the emulator, in the routine listed above, it seems
to work just fine although it takes a while before returning
"UnknownHost". I say it works just fine because of what I can see in
the Log results.

It does however display the error "Application MyApp (in process
mnt.android.myapp.MA103) is not responding." along with a Force Close
button and a Wait button. If I wait a moment and press the Wait
button, the app proceeds like it should.

What can I do to avoid the long wait (and error) when there is no
service?

Thanks, John Brown

-- 

3. SIM state ready intent

4. To the Moderators: is there a way to find my earlier post threads?

5. What is exactly the X and Y coordinates in method "canvas.rotate"

6. Problem with HttpsURLConnection

7. Webview inside Scroll doesn't resize