On Mon, May 28, 2012 at 5:51 AM, Ralph Bergmann | the4thFloor.eu <ra...@the4thfloor.eu> wrote: > Why the callback method must be in the FragmentActivity class and not in > the Fragment class?
Because android:onClick was added in Android 1.6, well before the existence of fragments, and we have not invented a time machine that would let us go back in time and change all pre-Android 3.0 devices to behave differently. While the Android Support package can add backports of *new* stuff, it cannot change the behavior of *existing* stuff that well. Hence, you have to inherit from FragmentActivity. Now, I have not examined where exactly the android:onClick wiring exists in the source code. It is conceivable, though unlikely, that the right overrides in FragmentActivity could handle this. However, probably then you will run into corresponding problems once you drop the fragments backport in late 2013 and go with native-only fragments, as I am not aware that native fragments handle android:onClick any differently than does the backport. I agree that having android:onClick route to the containing Fragment first would be a nice feature. Note that there is nothing stopping you (or anyone else) from cooking up a bit of code that takes ralph:onClick attributes and wires them up to the containing Fragment. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training...At Your Office: http://commonsware.com/training -- 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