标签: react-native-android

找不到变量:导航

我正在尝试借助来在两个屏幕之间导航react-navigation。我可以navigate在render方法内部访问,因为它的范围也在该方法内部。

我应该在哪里声明,以便可以访问this的任何方法component。我正在尝试访问方法navigate内部,onPressButton但它给出了错误。

找不到变量:导航

import React, { Component } from "react";
import { View, Text, Image, Button, Alert, StyleSheet } from "react-native";
import styles from "./Styles";
import * as strings from "./Strings";
import RoundButton from "./RoundButton";
var DialogAndroid = require("react-native-dialogs");
import { StackNavigator } from "react-navigation";

export default class CreateMessageScreen extends Component {
  render() {  
    const { navigate } = this.props.navigation;

    return (
      <View style={styles.container}>
        <Image source={require("./img/create_message.png")} />
        <Text …
Run Code Online (Sandbox Code Playgroud)

javascript android reactjs react-native react-native-android

6
推荐指数
1
解决办法
2万
查看次数

单选按钮在Native-Base中不起作用

我正在使用Native-Base.我需要使用单选按钮,但它们不起作用.当你点击没有任何反应.这是代码.

import React, { Component } from 'react';
import { Container, Header, Content, ListItem, Text, Radio, Right } from 'native-base';
export default class RadioButtonExample extends Component {
  render() {
    return (
      <Container>
        <Header />
        <Content>
          <ListItem>
            <Text>Daily Stand Up</Text>
            <Right>
              <Radio selected={false} />
            </Right>
          </ListItem>
          <ListItem>
            <Text>Discussion with Client</Text>
            <Right>
              <Radio selected={true} />
            </Right>
          </ListItem>
        </Content>
      </Container>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能使它工作?请不要发送仅包含单选按钮功能的不同库.我已经检查了不同的单选按钮库.只需要在此代码中添加一些内容即可使其正常工作.

react-native react-native-android native-base react-native-ios

6
推荐指数
2
解决办法
5753
查看次数

在我分离我的反应原生应用程序后,我仍然可以使用世博会吗?

我想使用expokit和其他本机库,我该怎么做?

我是否需要使用create-react-native-app启动我的应用程序,然后将其分离,或者我可以从react-native init应用程序启动?

reactjs react-native react-native-android react-native-ios

6
推荐指数
1
解决办法
564
查看次数

“在Android上使用react-native-maps使用newLatLngBounds(LatLngBounds,int)时出错:地图大小不能为零...。”

我收到一个错误:“使用newLatLngBounds(LatLngBounds,int)时出错:地图大小不能为零。最有可能的布局尚未出现在地图视图中。要么等待布局发生,要么使用newLatLngBounds(LatLngBounds(LatLngBounds,int,int) ,int),它允许您指定地图的尺寸​​”。

但是我为getCurrentPosition设置了警报,并且正在从getCurrentPosition()接收坐标。

import React, { Component } from 'react';
import { View, Dimensions } from 'react-native';
import MapView from 'react-native-maps';


const {width, height} = Dimensions.get('window')

const SCREEN_HEIGHT = height
const SCREEN_WIDTH = width
const ASPECT_RATIO = width / height
const LATITUDE_DELTA = 0.0922
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO


class Map extends Component {
	
	constructor(props) {
		super(props)

		this.state = {
			isMapReady: false,
			initialPosition: {
				longitude: 0,
				latitude: 0,
				longitudeDelta: 0,
				latitudeDelta: 0
			},

			markerPosition: {
				longitude: 0,
				latitude: 0 …
Run Code Online (Sandbox Code Playgroud)

android reactjs react-native react-native-android react-native-maps

6
推荐指数
3
解决办法
5095
查看次数

中心组件如何在React Native中使用Flex?

我很难使用CSS在屏幕上集中我的组件。

看我的App.js:

import { Container } from 'native-base';
import React from 'react';
import { StyleSheet } from 'react-native';

import Screen from './ScreenContainer';

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#FF6666',
    flex: 1
  }
});

const App = () => (
  <Provider store={store}>
    <Container style={styles.container}>
      <Screen />
    </Container>
  </Provider>
);

export default App;
Run Code Online (Sandbox Code Playgroud)

现在,看看我的 ScreenContainer.js

import { Container, Content, Form, Input, Label, Item } from 'native-base';
import React from 'react';

import AppLogo from '../components/AppLogo';

const Screen = () => …
Run Code Online (Sandbox Code Playgroud)

css flexbox reactjs react-native react-native-android

6
推荐指数
2
解决办法
1万
查看次数

在RN中获取当前用户坐标的最佳方法是什么?

我想创建一个用于获取用户坐标的函数,但我发现我不确定我的方法是否足够好.
我想知道其他人如何编写这个函数,以便在ios和android上100%确定.
现在我有这样的事情:

function getUserLocation(callback: func) {
  Permissions.check('location')
  .then(response => {
    if (response == 'authorized') {
      navigator.geolocation.getCurrentPosition(
        (location) => {
          callback({
              latitude: location.coords.latitude, 
              longitude: location.coords.longitude
            }, response);
        },
        (error) => {
          callback(null);
        },
        Platform.OS === 'android' ? null : {enableHighAccuracy: true, timeout: 100000, maximumAge: 1000}
      );
    } else {
      callback(null, response);
    }
  })
}
Run Code Online (Sandbox Code Playgroud)

因此,您可以看到我想使用此函数,因此调用者可以知道是否允许使用位置以及是否获取当前坐标.
我正在尝试的是学习如何:

1.使这样的功能等待.
2.其他人如何使这样的功能(对于两种操作系统)和100%相同的功能.

ecmascript-6 react-native react-native-android react-native-ios

6
推荐指数
1
解决办法
633
查看次数

React Native:双击后退到应用程序

如何在不需要Redux的情况下两次单击后退按钮退出应用程序

我一直在寻找一种限制用户的解决方案,只需点击一下本机就可以退出应用程序.

double-click exit react-native react-native-android react-native-ios

6
推荐指数
4
解决办法
6532
查看次数

使用react-native router-flux时,BackHandler无法在react-native side-menu中工作

我正在研究react-native来开发一个示例应用程序.在我使用backHandlerreact-native side-menu组件时,我遇到了一个问题.

实际上,侧边菜单包含更多页面!但是当单击侧面菜单页面中的Android后退按钮时,只有后退处理程序工作.在这里,我使用react-native router-flux.

这里的后退按钮动作只调用一次!

这是我的代码:

componentDidMount() {
    BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
}

componentWillUnmount() {
    BackHandler.removeEventListener('hardwareBackPress', this.handleBackPress);
}

handleBackPress = () => {
    let {isGoback} = this.props.isGoback
    //alert("Hi " + isGoback)

    if(isGoback === "Contact Us"){
        //alert("Hi: " + isGoback)
        Actions.BasicSideMenuMain({selectedItem:'Home'});
        //Actions.replace('BasicSideMenuMain')
    }
}
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android react-native-router-flux react-native-navigation

6
推荐指数
1
解决办法
257
查看次数

在react-native中导入com.android.build.OutputFile错误

首先,我运行一个新项目

react-native init AwesomeProject --version 0.58.6
Run Code Online (Sandbox Code Playgroud)

(0.59.1有一个错误,但我对此进行了测试)

与react-native run-android我可以运行它。

在android studio中,当我同步它时,出现错误:

app / build.gradle:

import com.android.build.OutputFile
Run Code Online (Sandbox Code Playgroud)

错误:无法解析符号“ build”

我使用以下版本:

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 27
    supportLibVersion = "28.0.0"
}
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
Run Code Online (Sandbox Code Playgroud)

android android-gradle-plugin react-native react-native-android

6
推荐指数
1
解决办法
745
查看次数

响应本机时遇到的问题“无法安装应用程序。确保您具有Android开发环境”

您能帮我吗,我很想在react-native这样的屏幕截图中创建一个新项目。我能够运行旧项目。但我无法运行新项目

我已按照以下步骤操作:

  1. react-native init projectName
  2. cd projectName
  3. react-native run-projectName

但是我得到以下错误:

error Failed to install the app. Make sure you have the Android development environment set up:
Run Code Online (Sandbox Code Playgroud)

屏幕截图

android-sdk-tools react-native react-native-android

6
推荐指数
10
解决办法
1万
查看次数