Ok, I know the extends Activity part is wrong (Both because I want to use the current Activity in B4A and the XML grabs all of it for a massive dropdown list in B4A), but what I'm trying to do is make a library to build my layout by code and use Relative Layout. Not much code as I'm just testing how it can work, but how do I use setContentView with a B4A Activity? I can't find it in any B4A classes and it is only available when extending Activity.
addView wouldn't work with the B4A view wrapper either...I had code to check if initialized and such assuming they would need at least that. Martin had some code where he successfully pulled in an XML layout at http://www.b4x.com/forum/bugs-wishlist/18717-wish-automatically-save-restore-view-state.html which I may do if this doesn't work, but I'd really like to just make a library to add the views by code.
addView wouldn't work with the B4A view wrapper either...I had code to check if initialized and such assuming they would need at least that. Martin had some code where he successfully pulled in an XML layout at http://www.b4x.com/forum/bugs-wishlist/18717-wish-automatically-save-restore-view-state.html which I may do if this doesn't work, but I'd really like to just make a library to add the views by code.
B4X:
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.ActivityObject;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import android.app.Activity;
@ActivityObject // Marking your class with this annotation will make it an activity object.
@ShortName("RelativeLayout") // this is the name as it appear on the IDE
@Permissions(values = {}) // Permissions must always be declared otherwise your app or library won’t work.
@Author("Roger Garstang")
@Version(1f) // the version
public class RelativeLayout extends Activity {
private android.widget.RelativeLayout myLayout = new android.widget.RelativeLayout(BA.applicationContext);
public RelativeLayout() {
}
public void AddView(android.view.View View) {
myLayout.addView(View);
}
public void DrawLayout() {
setContentView(myLayout);
}
}