I'm new to NativeScript, I'd like to know what is the equivalent of Android Fragments in NativeScript and how to use it.
I'm new to NativeScript, I'd like to know what is the equivalent of Android Fragments in NativeScript and how to use it.
Using Placeholder you can use the Android Fragments.The Placeholder allows you to add any native widget to your application. To do that, you need to put a Placeholder somewhere in the UI hierarchy and then create and configure the native widget that you want to appear there. Finally, pass your native widget to the event arguments of the creatingView event.
<Placeholder (creatingView)="creatingView($event)"></Placeholder>
public creatingView(args: any) {
let fragment = new org.nativescript.Test.Fragment();
let fragmentManager: android.app.FragmentManager = application.android.startActivity.getFragmentManager();
let fragmentTransaction = fragmentManager.beginTransaction();
let framelayout = new android.widget.FrameLayout(args.context);
framelayout.setId(android.view.View.generateViewId());
args.view = nativeView;
}