Is there a way to set the content of a NativeActivity to a component created in Java (such as a FrameLayout, ImageView, etc)? I have a need to use a NativeActivity (for get
I'll post the answer here for others with the same problem, since I did eventually figure out a method that works.
In the onCreate() method, if you are setting any particular window flags (FEATURE_NO_TITLE, FLAG_FULLSCREEN, FLAG_KEEP_SCREEN_ON, etc) do those before you call super.onCreate() (or they'll be ignored). Then wherever you would normally put this:
setContentView( whatever );
Do this instead:
getWindow().takeSurface( null );
getWindow().setContentView( whatever );
That's the basic way to get the content to be controlled from the Java side. Any place in your code where you deal with the content, use "getWindow()" instead of "this".
Some other things to keep in mind, are that the normal onKey and onTouch methods will not be called (their native equivalents will be instead), so if you need to be able to process input on the Java side, you'll have to set up some JNI linkage to send the information from native to Java. I believe everything else is included in the official XPeria Play touchpad sample code (the additions to the AndroidManifest.xml and what-not).
If you want to look at my project for reference, it is open-source and can be found at:
http://www.paulscode.com/forum/index.php?topic=75.msg1540#msg1540
Just click the "source code" link next to "XPeria Play Touch-Pad Example". It may not be all that useful to you though, because it is a rather large project and may be difficult to find what you are looking for. If you have any problems, post a question on my forum there or email me, and I'll be happy to help.