如何在Android Studio中导入React Native项目 [英] How to import react native project in android studio
问题描述
我开始使用atom
文本编辑器开发android应用程序.只要我用JS和JSX编写代码,它就可以正常工作.
I started development of the android application using atom
text editor. It is working fine as long I am writing code in JS and JSX.
我必须做在react native中不可用的功能,所以我需要像
I have to do functionality which is not available in react native, so I need to write java code as like https://facebook.github.io/react-native/docs/native-modules-android.html
ToastModule.java
package com.facebook.react.modules.toast;
import android.widget.Toast;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import java.util.Map;
public class ToastModule extends ReactContextBaseJavaModule {
private static final String DURATION_SHORT_KEY = "SHORT";
private static final String DURATION_LONG_KEY = "LONG";
public ToastModule(ReactApplicationContext reactContext) {
super(reactContext);
}
}
我不想在atom
中编写Java代码,因为建议不起作用.我们可以在Android Studio中导入我们的react native项目吗,那里有所有内置的react native内置类,因此我在编写代码时可以对类/方法提出建议.
I do not want to code Java in atom
as suggestions are not working. Can we import our react native project in android studio where all in built classes of react native are available so I can have suggestion of classes/methods while writing code.
有什么办法吗?
推荐答案
转到Android Studio->然后打开您的RN项目的Android文件夹
Go to Android Studio--> then open the Android folder of your RN project
如果您需要代码建议,则在输入;)时Android Studio将为您提供帮助
If you want code suggestions, Android Studio will help you while typing ;)
这篇关于如何在Android Studio中导入React Native项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!