百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-native-android-fragment

> 编程语言
开源

已弃用: 一个实用性库,用于简化使用 Android Fragment 开发 React Native。

99 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

已弃用: 一个实用性库,用于简化使用 Android Fragment 开发 React Native。

DEPRECATED

This library has been deprecated and is no longer in use at Hudl. If you've been using this library, please consider adopting ReactFragment in the main react-native repo.

react-native-android-fragment

A utility library for facilitating React Native development with Android Fragments.

Getting started

$ npm install react-native-android-fragment --save

or

$ yarn add react-native-android-fragment

Mostly automatic installation

$ react-native link react-native-android-fragment

Manual installation

Android

  1. Append the following lines to android/settings.gradle:
    include ':react-native-android-fragment'
    project(':react-native-android-fragment').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-fragment/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
    compile project(':react-native-android-fragment')
  3. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.hudl.oss.react.fragment.ReactFragment; to the imports at the top of the file

Usage

The primary component in this library is ReactFragment You can use this class directly if you wish, or you can extend from it to simplify your code.

A Builder pattern is provided out of the box for easy usage:

java
Fragment messagingFragment = new ReactFragment.Builder()
       .setComponentName("HelloWorld")
       .setLaunchOptions(launchOptions) // A Bundle of launch options
       .build();

In your Activity make sure to override onKeyUp() in order to access the In-App Developer menu:

java
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    boolean handled = false;
    Fragment activeFragment = getSupportFragmentManager().findFragmentById(R.id.container_main);
    if (activeFragment instanceof ReactFragment) {
        handled = ((ReactFragment) activeFragment).onKeyUp(keyCode, event);
    }
    return handled || super.onKeyUp(keyCode, event);
}

Running Sample App

NOTE: Make sure your environment is set up for React Native and Android development.

  • Clone the repo
  • Open a terminal and navigate to the root directory of your checkout
  • yarn link
  • cd example
  • yarn link react-native-android-fragment
  • react-native link react-native-android-fragment
  • react-native run-android

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言