On 03/17/2010 03:46 PM, Mark Murphy wrote:
mike wrote:
We're not communicating. Are you saying that the only time
I should do a new XX() is *only* in onCreate?
No, we're definitely not communicating.

As I wrote:

1. Never implement a constructor in an Activity.

In Java, "implement" means "to write code".

Your sample code had:

public HelloActivity() {
     }

Do not do this in an Activity (or Service, for that matter). Or, as I
also wrote:

2. If you choose to violate rule #1, chain to the superclass.

That would mean adding a call to super() in the otherwise do-nothing
implementation of HelloActivity().

Oh! You should take that up with Google then because that's their
HelloActivity example code. I didn't change a thing there. If it
causes trouble, it's probably endemic because Hello World is where
most beginners start.

(actually, I used the android/eclipse start-with-example-project
 option. I assume it's getting the example code from the sdk, but
 i don't know that for certain.)

As you pointed out, these flaws did not impact the test case, but they
could have. In fact, I'm kinda surprised the activity survives not
having the activity's constructor called. Gotta look up Activity in the
source code sometime to see what symptoms you'd get for doing that...

Mike, I'll look at view flipper. View.GONE would be really cumbersome
and inelegant
:: shrug ::

I think calling setContentView() outside of onCreate() is cumbersome and
inelegant, but, to each their own.


Why? Is there actually some sort of proscription against calling
setContentView more than once? I've been using it this way for the
last year and a half and have never had a problem except for this.
As I mentioned, Intents would be horrible because you'd end up
refreshing the webview each time that the user popped back and forth.
I'm still looking at the ViewFlipper, but I'm rather nervous that it
will behave the same way.

Mike

--
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