Question

I don't think my future lies in Android development, as I am consistently failing at the simplest things...

I've got a button with the label "Game Slot 1". When the user clicks it, I succesfully take them through a couple of activities in which they create a new character. I save the game name in an SQLite database, and the next time I launch my app, I can quite happily dynamically change "Game Slot 1" to the name of that slot's game from the database. Perfect.

But how on earth do I get it to update the view in the same manner when I return to that activity via the back button, or having called finish() on all the subsequent activities?

I'm sure it's something to do with onResume(), and maybe invalidate(), but I just can't seem to find an example.

Is invalidate overkill just to refresh a few UI elements onResume()?

How the heck do you use it, anyway, even if it is?

Is there a better way?

Many thanks in advance for any help offered...just try not to laugh at how simple this probably is! :)

Cheers, James

Was it helpful?

Solution

That sounds like something you could do in onResume, just query the database and call setText on the element of interest. You should not need to explicitly call invalidate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top