TextView.setText doesn't update

by Midian » Tue, 14 Apr 2009 13:04:40 GMT


Sponsored Links
 I have a Timer set up to update a TextView field once every second.
Thing is, I can't see any changes on screen!

Debugging shows...
setText inside the timer function *is* being called.
getText called on the text view returns the *correct* (new) text that
just isn't displayed!

I've tried TextView.postInvalidate() to no effect.
Code below.

Anyone seen this before?
Thanks.

----------------------------------------------------------------------------------------
IN MyActivity.onCreate:
        mMyTextView = (TextView)this.findViewById
(R.id.txtcurloctitle);

FROM MyTimerTask.Run
        String timeSinceUpdate = tracker.getUpdateAge();
        mMyTextView .setText("Current location (" + timeSinceUpdate +
"):");

IN MyActivity.onOptionsItemSelected:
        AlertDialog.Builder msg = new AlertDialog.Builder(this);
        msg.setTitle("Debug");
        msg.setMessage(mMyTextView.getText());
        msg.setPositiveButton("OK", null);
        msg.show();

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



TextView.setText doesn't update

by Peter Carpenter » Wed, 15 Apr 2009 02:05:53 GMT


 Hi,

I'm not sure which thread timers fire in, but have you tried calling the
setText explicitly from the UI thread?

final String timeSinceUpdate = tracker.getUpdateAge();
runOnUiThread(new Runnable()
{
    public void run()
    {
        mMyTextView .setText("Current location (" + timeSinceUpdate +
")";
    }
}

Peter.

-----Original Message-----
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Midian
Sent: Tuesday, 14 April 2009 9:44 AM
To: Android Developers
Subject: [android-developers] TextView.setText doesn't update


I have a Timer set up to update a TextView field once every second.
Thing is, I can't see any changes on screen!

Debugging shows...
setText inside the timer function *is* being called.
getText called on the text view returns the *correct* (new) text that
just isn't displayed!

I've tried TextView.postInvalidate() to no effect.
Code below.

Anyone seen this before?
Thanks.

------------------------------------------------------------------------
----------------
IN MyActivity.onCreate:
        mMyTextView = (TextView)this.findViewById
(R.id.txtcurloctitle);

FROM MyTimerTask.Run
        String timeSinceUpdate = tracker.getUpdateAge();
        mMyTextView .setText("Current location (" + timeSinceUpdate +
"):");

IN MyActivity.onOptionsItemSelected:
        AlertDialog.Builder msg = new AlertDialog.Builder(this);
        msg.setTitle("Debug");
        msg.setMessage(mMyTextView.getText());
        msg.setPositiveButton("OK", null);
        msg.show();




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


Sponsored Links


Other Threads

1. Subscription Based Billing

If anyone needs subscription based billing setup for their Android
application, shoot me an e-mail. We are setting this up at
http://slideme.org and I want to make sure that we get everyone in the
system who wants subscription billing prior to launch.

Thanks,
Shane

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

2. COMMENT REQUESTED - method for _vastly_ improving text input speed on 12-key keyboards

I apologize that this got so long; I just very much care about both of
these points and I hope I can get some sympathy from the world out
there:


First thing is, we don't want the user to have to re-learn anything.
So the typical T9-style (or standard ordered-input) approach is
probably good.  I would propose only two changes, both of which make
their respective input models suck way less:

(1) predictive text is brilliant.  adaptable predictive text is _way
less_ brilliant.  here's the user story to explain why:

My wife and I have recently had our first child, a little girl.  And
we have been basically staring at her and drooling for the entire 13
days of her life outside the womb thus far.  We have also been sending
MMS and SMS messages like there's no tomorrow.  But a couple days ago
I went to work and on the way I had a text message come in from a
(particularly attractive) female colleague.

She wanted to be added to the list of people to receive e-mail alerts
about a particular department's goings-on in the office.

Her message read: "I would also like to receive your department's e-
mails."

I was driving, so I didn't care to stare at the screen of my phone
while texting my reply.

A few minutes after I got to work, I was called into my manager's
office.  I had to explain why I had just told a colleague "I have to
bed you before you can receive them."

PREDICTIVE TEXT INPUT SHOULD HAVE AN EASY STRUCTURE THAT WE CAN USE
WITH OUR EYES SHUT.  IT'S WHY SOME OF US STILL CHOOSE TO HAVE BUTTONS
ON OUR TELEPHONES.  The m{*filter*}of the story is: don't let the phone
change the order of possible words.

(2) The most important key for anyone with a keyboard is the "last-key-
pressed" key.  It eliminates the last slowdown of a fast typist in
this way: when you are working out a sequence of key presses on your
keyboard, the "next" finger is always already on its way down as the
"current" finger is registering its keypress.  Everything is nice and
sequential and the only waiting we do is in the tiny interval between
key switches actuating.  A fast typist works hard to eliminate the gap
between each two key presses.

HOWEVER, when pressing the same key twice in a row, suddenly you don't
get to combine the "pressing here" and "attacking there" motions.  You
have to lower your finger, press the key, raise your finger, lower
your finger, and press the key again before the regular, fast
operation of your keyboard can resume.

The "LAST KEY PRESSED" key should be accessible to both thumbs --
under the space bar.  This way when I have to type "assessment"
there's no slowdown.  I can type a different key using a different
finger for each keystroke in the ordering.

LIKEWISE, ON A 12-KEY MOBILE PHONE KEYBOARD: If I have to type
"federally" it is an ordeal:

333 (pause or right arrow) 33 (pause or right arrow) 3 (pause or right
arrow) 33 777 2 555 (pause or right arrow) 555 999

That's going to take all day.  Instead I want to use one of either *
or # as my 'last key pressed' key, so I can eliminate all delays no
matter what.  This way, when I press 333 to make an F, I can
immediately press ** to make an E:

333**3**7772555***999 and there's no pausing, no waiting, no endless
stupidity.

Please offer up your thoughts / responses to these possible
conveniences.  I'm talking about the cessation of reordering of t9
word choices and the use of a different key as your 'last-key-pressed'
key for eliminating the delay or right-arrow presses in standard
ordered input.

Thanks much,

~ dan ~
[EMAIL PROTECTED]

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

3. Problem running Hello Word app

4. Keyboard Layouts on various devices

5. Web service using XML-RPC working on Android SDK 0.9

6. Prevent uninstallation of application in Android

7. Restriction on Android.jar!