Open shexiaoheng opened 7 years ago
Native iOS jump to ReactNative then push pick correct, ReactNative push pick is correct, Native Android jump to ReactNative then push pick err,
Version
react-native-picker v4.0.16 react-native v0.40
1.AndroidManifest.xml add permission 2.addPackage(newImagePickerPackage())----in ReactNative Activity 3.settings.gradle add some code 4.build.gradle add some code 5.and rebuild the project
6Android hava a button ,then jump to ReactNative Activity(if only ReactNative is ok,to show picker)
7.In ReactNative Activity click a button,to show this -picker
8.The steps are the same, but other components can
@shexiaoheng
测试过了,没有发现你说的问题。 只要是 undefined is not an object (evaluating 'Picker._init') 这个错误,没有别的,一定是组件没有引入成功,参考 #98 第7条回复
@shexiaoheng 大神你看看我是安卓项目下集成你的组件,然后点击不显示,如果是纯ReactNative就可以显示..
检查下面的这些文件:
include ':react-native-picker'
project(':react-native-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-picker/android')
compile project(':react-native-picker')
import com.beefe.picker.PickerViewPackage;
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected List
@shexiaoheng 1.
2. 3.
4,纯RN就可以,但是我的是安卓里面有一个入口点击进入RN,就不行了..其他的第三方组件有些可以有些不可以
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new PickerViewPackage() // Added there
);
}
这个文件在哪里
@shexiaoheng 有没有QQ或者微信搞搞聊聊啊大神 这个是全局应用..我加了也没用的
react-native: v0.40 不会出现你的这些代码:
应该是这样的:
public class ShowAty 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 "PickerTest"; // 你的项目的名字
}
}
@shexiaoheng 还是不行
? 我说的是下面的这些代码是不应该出现的
那我怎么跳转到ReactNative入口界面...我现在安卓项目集成ReactNative...不是纯ReactNative
参考下我写的例子:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RelativeLayout layout = new RelativeLayout(this);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
);
layout.setLayoutParams(params);
Button button = new Button(this);
button.setText("点击跳转");
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT
);
lp.addRule(RelativeLayout.CENTER_IN_PARENT);
button.setLayoutParams(lp);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, ShowAty.class));
finish();
}
});
layout.addView(button);
setContentView(layout);
}
}
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new PickerViewPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
public class ShowAty 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 "PickerTest";
}
}
也就是你用react-native init project_name
创建完项目后,新建一个类,把原来MainActivity
的代码移过去,在新创建的类里面去做你本地要做的事
我再试试.谢谢
如果是iOS使用这个控件,也需要在 native的配置中,写额外的东西么。
@shexiaoheng 朋友求帮解决一下我ios 出现了 “Cannot read property '_init' of undefined” ,不知道如何解决
If this error occurs, please refer to this wiki first , or view this issues #98 Do not open new issues ! Thanks !