gpt4 book ai didi

java - 注册模块 mainactivity.java react native

转载 作者:行者123 更新时间:2023-11-30 01:29:06 25 4
gpt4 key购买 nike

我正在尝试按照这些说明进行操作:https://www.npmjs.com/package/react-native-text-input-layout .我对 mainactivity.java 部分的 register 模块感到困惑。我的 mainactivity.java 看起来与说明中的完全不同。

这是我的mainactivity.java:

package com.starterkit;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends ReactActivity {

/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "StarterKit";
}

/**
* Returns whether dev mode should be enabled.
* This enables e.g. the dev menu.
*/
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
}

这是说明中的 mainactivity.java:

 import com.memox.rntextinputlayout.RNTextInputLayoutPackage;  // <---       import 

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
......

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);

mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new RNTextInputLayoutPackage()) // <------ add this line to your MainActivity class
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();

mReactRootView.startReactApplication(mReactInstanceManager, "AndroidRNSample", null);

setContentView(mReactRootView);
}
......
}

最佳答案

你可以这样添加:

protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
,new RNTextInputLayoutPackage()
);
}

关于java - 注册模块 mainactivity.java react native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36009465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com