当我在进行库的设置时,遵循以下内容:https : //github.com/crazycodeboy/react-native-splash-screen我发现在MainActivity.java中不再有onCreate方法。
MainActivity.java RN 0.60
package com.testApp;
import com.facebook.react.ReactActivity;
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 "testApp";
}
}
因此,我尝试在getMainComponentName方法中进行设置:MainActivity.java
package com.testApp;
import com.facebook.react.ReactActivity;
import org.devio.rn.splashscreen.SplashScreen;
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() {
SplashScreen.show(this);
return "testApp";
}
}
但是当我尝试编译它给我这个错误: error: cannot find symbol variable SplashScreen
有人知道该怎么做吗?
覆盖MainActivity内部的onCreate方法,如下所示:
@Override
protected void onCreate(Bundle savedInstanceState){
SplashScreen.show(this);
super.onCreate(savedInstanceState);
}
别忘了import android.os.Bundle
和import org.devio.rn.splashscreen.SplashScreen;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句