新建Activity 继承ReactActivity 然后
在布局文件中写上主要的
android:orientation="vertical"android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/test_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="sdsdsds"
/>
android:id="@+id/test_js"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/test_text"/>
public classIndexActivityextendsReactActivity {
@Override
protected voidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_index);
ReactRootView mReactRootView = (ReactRootView) findViewById(R.id.test_js);
ReactInstanceManager mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index2.android.bundle")
.setJSMainModuleName("RC20170722")
.addPackage(newMainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager,"RC20170722", null);
}
}
打包命令其他篇幅已经说了