我创建了一个CustomView SignatureView.java,它扩展了LinearLayout以捕获Android Native中的签名.
并创建了SignatureCapturePackage.java和SignatureCaptureViewManager.java
public class SignatureCaptureMainView extends LinearLayout {
....
public void saveImage(){
//Save image to file
}
}
Run Code Online (Sandbox Code Playgroud)
这个Package类
public class SignatureCapturePackage implements ReactPackage {
private Activity mCurrentActivity;
public RSSignatureCapturePackage(Activity activity) {
mCurrentActivity = activity;
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
return Arrays.<ViewManager>asList(new SignatureCaptureViewManager(mCurrentActivity));
}
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Arrays.asList();
}
}
Run Code Online (Sandbox Code Playgroud)
这是ViewManager类
public class SignatureCaptureViewManager extends ViewGroupManager<SignatureCaptureMainView> {
private Activity mCurrentActivity;
public static …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用onViewableItemsChanged事件来检测当前显示在屏幕上的 FlatList 的项目。
在我的 ViewabilityConfig (下面提供了代码)中,我将itemVisiblePercentThreshold参数设置为 100,我认为这将要求我的项目完全显示才能被视为可查看。但对我来说情况并非如此。
正如您在下面的屏幕截图中看到的: 我的应用程序的屏幕截图
很明显,最上面的项目没有完全显示在屏幕上(这应该使可见项目仅包含 3 个项目)。但是,当我在onViewableItemsChanged事件处理程序中打印数组的长度时,它返回 4(当我检查值时,包括最上面的项目)。
这是 FlatList onViewableItemsChanged事件的问题吗?或者我实施得不正确?
我试图从文档和 React-native github 中找到解决方案,但没有关于此事件如何工作的进一步解释。
我的代码的一些相关片段如下:
平面列表定义
<FlatList
viewabilityConfig={this.clippingListViewabilityConfig}
inverted={true}
horizontal={false}
data = {this.props.clippingResultArray}
ref={(ref) => this.clippingResultFlatList = ref}
style={{
// flexGrow:0,
// backgroundColor: 'green',
// width:'100%',
// width: Dimensions.get('window').width,
}}
contentContainerStyle={{
// justifyContent:'flex-end',
// flexGrow:0,
// flexDirection:'row',
// alignItems:'flex-end',
}}
renderItem={this.renderClippingListItemRight}
keyExtractor={(item, index) => index.toString()}
onViewableItemsChanged={this.onClippingListViewableChanged}
// removeClippedSubviews={true}
{...this._clippingListItemPanResponder.panHandlers}
/>
Run Code Online (Sandbox Code Playgroud)
onViewableItemsChanged 侦听器
onClippingListViewableChanged = …Run Code Online (Sandbox Code Playgroud) 安装一些类似react-native-safe-area-context或 的软件包后react-native-screen,我总是遇到这个问题:无法运行该应用程序
当我运行yarn android时:
> Configure project :react-native-async-storage_async-storage
Subproject ':react-native-async-storage_async-storage' has location 'D:\ewm\git\itc\node_modules\@react-native-async-storage\async-storage\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0.
> Configure project :react-native-safe-area-context
Subproject ':react-native-safe-area-context' has location 'D:\ewm\git\itc\node_modules\react-native-safe-area-context\android' which is outside of the project root. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0.
> Task :react-native-safe-area-context:compileDebugKotlin
w: D:\ewm\git\itc\node_modules\react-native-safe-area-context\android\src\main\java\com\th3rdwave\safeareacontext\SafeAreaView.kt: (50, 23): 'getter for uiImplementation: UIImplementation!' is …Run Code Online (Sandbox Code Playgroud) 结帐后,当我说react-native run-android im低于错误时。
Metro Bundler has encountered an internal error, please check your terminal error output for more details
Run Code Online (Sandbox Code Playgroud)
下面是我项目中的package.json。
{
"name": "NCAPRNRedux",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.2.0",
"react-native": "0.52.2",
"react-native-vector-icons": "^4.0.0",
"react-navigation": "^1.0.0-beta.29",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-jest": "22.1.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-react-native": "^4.0.0",
"jest": "22.1.4",
"react-test-renderer": "16.2.0"
},
"jest": {
"preset": "react-native"
}
}
Run Code Online (Sandbox Code Playgroud)
有人遇到这个问题并解决了吗?
我是React-native的新手.
我merge遇到了这个错误:UnableToResolveError:无法从Libraries/ART/ReactNativeART.js 解析模块
我使用的依赖项是:
"dependencies": {
"apsl-react-native-button": "^3.0.2",
"react": "16.0.0-alpha.6",
"react-native": "0.44.2",
"react-native-deprecated-custom-components": "^0.1.0",
.....................
},
Run Code Online (Sandbox Code Playgroud)
在node_modules中 - > react-native/Libraries/ART/ReactNativeART.js文件也可用.
当我运行react-native run-android命令时,我正面临这个错误.
任何人都可以帮助我吗?
我正在我的组件中进行一个简单的提取调用,看起来像这样
var x = fetch(SOME_URL, SOME_POST_DATA)
.then((response) => response.json())
.then((responseJSON) => {return responseJSON});
console.log(x);
Run Code Online (Sandbox Code Playgroud)
调用成功执行,但控制台打印了promise而不是数据.我在这里错过了什么?
无法加载文件 /Users/MyName/.android/repositories.cfg。
FAILURE:构建失败,出现异常。
出了什么问题:配置项目“:app”时出现问题。
无法解析配置“:app:_debugApk”的所有依赖项。配置项目 ':urbanairship-react-native' 时出现问题。无法解析配置 ':urbanairship-react-native:_debugPublishCopy' 的所有依赖项。找不到与 com.facebook.react:react-native:[0.40,) 匹配的任何版本。不匹配的版本: 0.20.1 0.20.0 0.19.1 0.19.0 0.18.0 + 12 more 需要:Koopi 客户:urbanairship-react-native:未指定
尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。
构建失败
总时间:15.647 秒 无法在设备上安装应用程序,请阅读上面的错误了解详情。确保您有一个正在运行的 Android 模拟器或已连接的设备并已设置您的 Android 开发环境:https : //facebook.github.io/react-native/docs/android-setup.html
我正在为抽屉项目和 headerLeft 设置图标。但是图标没有出现在我的 Android 应用程序中。我正在使用react-native-elements库在我的代码中使用图标。图标类型字体很棒。我已经具体提到了图标的类型。
我已经尝试了所有命令,例如react-native link,并成功链接了所有库,但没有任何效果。
主要组件.js
import React, { Component } from 'react';
import Menu from './MenuComponent';
import { View,Platform } from 'react-native';
import Dishdetail from './DishdetailComponent';
import Home from './HomeComponent';
import { createStackNavigator,createAppContainer} from 'react-navigation';
import {createDrawerNavigator} from 'react-navigation';
import { Icon } from 'react-native-elements'
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';
import Contact from './ContactusComponent';
import About from './AboutusComponent';
const MenuNavigator = createStackNavigator({
Menu: {
screen: Menu,
navigationOptions: ({ navigation }) …Run Code Online (Sandbox Code Playgroud) icons react-native react-android react-native-vector-icons react-native-elements
我试图从Android设备获取设备ID.有几个链接和包可用于获取设备ID,但在Android的情况下很少可用.以下是我已尝试过的链接,没有结果:
Link1:https://github.com/rebeccahughes/react-native-device-info 我试过这个链接没有成功它可能在ios上正常运行但在Android上它显示我在github链接上运行上述命令时出错"反应-native link react-native-device-info"错误:链接无法识别
Link2:https://github.com/lazywei/react-native-device-uuid 它只有IOS的解决方案
我被困在这里.我不知道我将如何解决这个问题?请帮忙?
提前致谢
android reactjs android-developer-api react-native react-android
我已将反应本机地图与最新的反应本机应用程序集成。在地图中,我想设置地图的边界。官方文档建议了该方法
setMapBoundaries ,但需要这样的论证northEast: LatLng, southWest: LatLng 。
我怎样才能获得这些参数的值。我的mapView是这样的。
<MapView
showsUserLocation
provider={MapView.PROVIDER_GOOGLE}
style={styles.map}
region={region}
onRegionChangeComplete={this.onRegionChangeComplete}
setMapBoundaries={}
onUserLocationChange={this.onUserLocationChange}
>
Run Code Online (Sandbox Code Playgroud) react-android ×10
react-native ×10
android ×3
javascript ×3
reactjs ×3
fetch ×1
gradle ×1
icons ×1
react-redux ×1