Maybe you can glean something from the source:

http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/app/Activity.java;h=f25c4c385e4f510bec426fbef801243e4c149f69;hb=cb8427538dfdc5eae941e377b11bfd11a95fc5a5

Looks like the title will only be changed if mTitleReady is true, which is set in onPostCreate.

You could add logging to onCreate, onActivityResult and your own overriden onPostCreate, just to see in what order they get called. If the order is not what you expect, try saving the title in onActivityResult and change it in your overriden onPostCreate.

-- Kostya

12.01.2011 21:39, Paul пишет:
UPDATE:

Ok, so it looks like the following is happening...  User starts the
activity, title is XXXXX.  As a test, I then change the title in
onCreateOptionsMenu to YYYYY, and the UI changes immediately.
Finally, when the options-menu launched activity returns it's value,
ZZZZZ to onActivityResult, I then attempt to change the UI title again
from the currently shown YYYYY to ZZZZZ... but the title is instead
changed back to XXXXX..., even though an immediate call to getTitle
tells me that it should be ZZZZZ...

Any ideas why this may be happening?

Paul

On Jan 12, 1:26 pm, Paul<pmmen...@gmail.com>  wrote:
Agreed, which is why it's so frustrating.

As a test, in onCreateOptionsMenu()

@Override
public boolean onCreateOptionsMenu(Menu menu) {
         setTitle("changed");
         .
         .
         .
         return super.onCreateOptionsMenu(menu);

}

Works fine.  In onActivityResult() (this is the code, verbatim)

     @Override
     protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
         super.onActivityResult(requestCode, resultCode, data);

         // check the activity results
         switch (requestCode) {
                 case RESULT_RENAME:
                         if (resultCode == -1) {
                                 // activity ended successfully
                                 Log.d(LOG_TAG, "onActivityResult():
Changing title from " + getTitle() + " to " +
data.getStringExtra(StylePad.Notes.TITLE));
                                 
setTitle(data.getStringExtra(StylePad.Notes.TITLE));
                                 Log.d(LOG_TAG, "onActivityResult():
New title " + getTitle());
                         }
                         break;
         }
     }

And the logging tells me that the title's been changed, but yet the UI
is NOT updated...  Have tried this on both a Galaxy Tab (2.2) and the
2.2 emulator.

On Jan 12, 12:16 pm, Kumar Bibek<coomar....@gmail.com>  wrote:

It's a relatively simple problem. I am not sure what are you doing wrong.
The title can be changed anytime from anywhere.
Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com
On Wed, Jan 12, 2011 at 10:43 PM, Paul<pmmen...@gmail.com>  wrote:
I posted this over at StackOverflow, but not much of a response...
maybe someone else can run this on their testbed and verify?  A
strange problem...
==
Hi all.  I have a simple app based on the Notepad demo application,
and when a user is viewing/editing a note they can launch a dialog
activity (TitleEditor) that allows them to change the title of a note.
Currently in the app, when viewing/editing a note, the notes' current
title is shown as the activity title.
So, I launch the TitleEditor dialog activity with
startActivityForResult(), and in onActivityResult() I am successfully
getting the new title back, no problem.
The issue relates to then updating the notes view/edit (the active
activity) title... using setTitle() in onActivityResult() with the
data passed back does seem to set the title internally (a subsequent
call to getTitle() shows the new title has been set), but the actual
UI title is not updated until the activity is closed and then re-
launched.
I've used setTitle() in onResume(), onPrepareOptionsMenu(), etc and it
worked like a charm, but not working here... any ideas or suggestions?
Thanks,
Paul
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to