Hello everyone, and thanks in advance for the help.  What I'm trying
to do is a relatively simple task, but one that doesn't seem to be
working.  What I'm trying to do is display the Orientation X,Y,Z
coordinates on the screen in basic TextView boxes.  The sensors are
constantly updating my Global.myOrientation float array, and then I'm
running a Timed thread (I'm very new to threading, so forgive me if
it's ugly, but it gets the job done almost).  In this thread I just
set the value of each TextView's text to the desired value.  The
problem is that it only seems to work the first time.

It correctly displays whatever my initial data is, but then subsequent
runs of the thread do nothign to update the onscreen values when I
change the orientation of the phone.  LogCat output shows me that
inside the run() method, the values of Global.getOrientationX,Y,Z are
being updated correctly, and that the right data is being passed to
TextView.  How can I get around this limitation of TextView being
initialized once and then immutable?

Any assistance in fixing this, or providing an alternate solution
would be greatly appreciated.  Code posted below:

public class DisplayOrientation extends Activity
{

        private static Timer time;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.variableviewelement);
    Log.d("DisplayOrientation", "onCreate");

    time = new Timer();
    UpdateO t = new UpdateO();

    time.scheduleAtFixedRate(t, 0, 300);
}


private class UpdateO extends TimerTask implements Runnable {
        @Override
        public void run() {
                Log.d("UPDATEO", "In run");
                Log.d("UUPDATE0", "xUp = " + Global.getOrientationX() + " yUp = 
" +
Global.getOrientationY()
                                + " zUp = " + Global.getOrientationZ());
            TextView tv1 = (TextView) findViewById(R.id.TextView01);
            TextView tv2 = (TextView) findViewById(R.id.TextView02);
            TextView tv3 = (TextView) findViewById(R.id.TextView03);
                tv1.setText("X = " + Global.getOrientationX() + "  ");
                tv2.setText("Y = " + Global.getOrientationY() + "  ");
                tv3.setText("Z = " + Global.getOrientationZ() + "  ");
        }
}
--~--~---------~--~----~------------~-------~--~----~
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