I am writing a react native application and I want to use some of the static layouts (for Android) I have from my old application.
I looked at https://facebook.github.io/react-native/docs/native-components-ios.html and wrote a few classes (MyViewManager.java and MyView.java).
I want to be able to use the static layouts I have for MyView.java.
I went through the facebook's react native code on github.
I could not find an appropriate method like setContentView(R.layout.myview). I was wondering if anybody tried this and this will work.
Can someone please help me with this problem?
You can try out something like
The layout inflater will inflate given xml file and put it as a child of this(second argument in inflate), which is MyLayoutView.
See the definition of inflate and change arguments as per customization required.
public class MyManyViewsManager extends ViewGroupManager<MyLayoutView> {
}
class MyLayoutView extends FrameLayout {
init() {
rootItem = (ViewGroup) LayoutInflater.from(getContext()).inflate(R.layout.xmlfilename, this, true);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With