如何在android studio中导入react native项目 [英] How to import react native project in android studio

查看:150
本文介绍了如何在android studio中导入react native项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用 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 中没有的功能,所以我需要像 https://facebook.github.io/react-native/docs/native-modules-android.html

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.

有没有办法做到这一点?

Is there any way to do this ?

推荐答案

进入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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆