在我们的React-native项目中,我们有一个屏幕,它有一个父Scrollview(带有pull to refresh),在scrollview中我们有Listview(作为chilld视图).
在iOS中,我们可以滚动Scrollview(父级)以及Listview(子视图).
但在android中,我们无法滚动Child Listview.当我们尝试滚动子Listview时,父视图将滚动.儿童视图没有获得触摸.
这与React-native问题有关吗?谁能告诉我如何解决这个问题?
代码段:
<ScrollView contentContainerStyle={styles.contentContainerStyle} refreshControl={this.getRefreshControl()}>
<View> Some header </View>
<MyComponent> </MyComponent>
<ListView /* This list view is not scrolling in Android */
dataSource={dataSource}
initialListSize={10}
renderRow={this.renderRow}
renderSeparator={this.renderSeparator}/>
</ScrollView>
Run Code Online (Sandbox Code Playgroud) 我收到以下错误.
Navigator已弃用,已从此包中删除.它现在可以从react-native-deprecated-custom-components安装和导入,而不是react-native.在http://facebook.github.io/react-native/docs/navigation.html上了解替代导航解决方案
然后我会更新react-native-deprecated-custom-components包但问题没有解决
的package.json
"dependencies": {
"react": "16.0.0-alpha.6",
"react-native": "0.44.2",
"react-native-deprecated-custom-components": "^0.1.0",
"sendbird": "^3.0.30"
},
Run Code Online (Sandbox Code Playgroud)
main.js
var React = require('react-native')
var {
Navigator,
StyleSheet
} = React;
var Login = require('./components/login');
import NavigationExperimental from 'react-native-deprecated-custom-components';
var ROUTES = {
login: Login
};
module.exports = React.createClass({
renderScene: function(route, navigator) {
var Component = ROUTES[route.name];
return <Component route={route} navigator={navigator} />;
},
render: function() {
return (
<NavigationExperimental.Navigator
style={ styles.container }
initialRoute={ {name: 'login'} }
renderScene={this.renderScene}
configureScene={ () => …Run Code Online (Sandbox Code Playgroud) react-native react-native-android react-native-ios react-navigation
我有问题,任何人都有这个想法
scrollview没有原生类型字符串的RCTScrollView.overScrollMode的proptype如果您自己没有更改此prop,这通常意味着您的本机代码版本和javascript代码不同步
当我们刚刚通过StackNavigator导航到当前屏幕时,是否可以告诉ScrollView滚动到特定位置?
我有两个屏幕。菜单和项目。菜单是按钮的列表,每个按钮一个。“项目”屏幕包含一个使用ScrollView构建的轮播,带有图片和每个项目的详细说明。
当我单击“菜单”屏幕中的按钮时,我想导航到“项目”屏幕,然后自动滚动到该按钮代表的项目。
我读到您可以像下面这样使用StackNavigator时传递参数:但是我不知道如何在我的“项目”屏幕中读出该参数。
navigate('Items', { id: '1' })
Run Code Online (Sandbox Code Playgroud)
那么这在React Native中是可能的吗,我该怎么做?还是我使用了错误的导航器?
这是我的两个屏幕的精简版:
App.js:
const SimpleApp = StackNavigator({
Menu: { screen: MenuScreen},
Items: { screen: ItemScreen }
}
);
export default class App extends React.Component {
render() {
return <SimpleApp />;
}
}
Run Code Online (Sandbox Code Playgroud)
Menu.js
export default class Menu extends React.Component {
constructor(props){
super(props)
this.seeDetail = this.seeDetail.bind(this)
}
seeDetail(){
const { navigate } = this.props.navigation;
navigate('Items')
}
render(){
<Button onPress={this.seeDetail} title='1'/>
<Button onPress={this.seeDetail} title='2'/>
}
}
Run Code Online (Sandbox Code Playgroud)
Items.js
export default class Items extends …Run Code Online (Sandbox Code Playgroud) react-native react-native-scrollview react-native-android react-navigation
我一直在尝试将Google Maps安装为react-native一周,但仍然没有成功。我已经搜索并尝试了react-native-maps github问题中的解决方案,但仍然出现空白页。
我所做的:
react-native init myapp
npm install
yarn add react-native-maps
react-native link react-native-maps
Run Code Online (Sandbox Code Playgroud)
在Google Console API中->创建新项目->启用Google Maps Android API,Google Maps JavaScript API和Places API->创建凭据
在AndroidManifest.xml中
<application>
....
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyDRK50sPCRCPLTnyt0OUdng9cwP0eqPJq4"/>
</application>
Run Code Online (Sandbox Code Playgroud)
package.json
{
"name": "maps",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.0.0",
"react-native": "0.50.4",
"react-native-maps": "^0.18.3"
},
"devDependencies": {
"babel-jest": "21.2.0",
"babel-preset-react-native": "4.0.0",
"jest": "21.2.1",
"react-test-renderer": "16.0.0"
},
"jest": {
"preset": "react-native"
}
}
Run Code Online (Sandbox Code Playgroud)
App.js
import React, { Component …Run Code Online (Sandbox Code Playgroud) 我在Android上收到此错误:
我'Sn[e]'在下面粘贴了'index.android.bundle'中的代码行(ctrl/command + F):
for (var An in Sn) xn[An] = Sn[An];
for (var Dn in wn) Pt(!Sn[Dn], "Event cannot be both direct and bubbling: %s", Dn), xn[Dn] = wn[Dn];
var kn = {
eventTypes: En({}, Sn, wn),
extractEvents: function(e, t, n, o) {
var r = Sn[e],
i = wn[e],
a = Pn.getPooled(r || i, t, n, o);
if (r) fn.accumulateTwoPhaseDispatches(a);
else {
if (!i) return null;
fn.accumulateDirectDispatches(a)
}
return a
}
},
jn = kn,
On …Run Code Online (Sandbox Code Playgroud) 安装我的应用程序后,有什么方法可以默认启用所有通知设置?
用户正在接收通知,但默认情况下声音是禁用的,我们需要在设备上手动启用它。并非所有用户都可以手动执行此操作。非常高兴知道在安装我们的应用程序后,是否可以通过任何方式检查所有这些内容,例如WhatsApp或Telegram(默认情况下,它们会进行所有检查)
我正在尝试开发一个react-native应用程序,以设计一个自定义主题组件,并使用将该屏幕包含在主题中this.props.child。问题是屏幕上的输入字段失去焦点,并且在键入每个字符后键盘都被关闭,因为onChange我正在更新状态变量,这可能会重新呈现整个主题。
我已经尝试过在Github上提供许多解决方案,例如将唯一键传递给输入字段,但是它们不起作用。
这是我的主题组件的样子:
import Header from './header'
import footer from './footer'
export default class Theme extends Component {
render() {
//------this is my header component----
<Header/>
<View>
//------this is my Body in which i include my sceen content----
{this.props.children}
</View>
//------this is my footer component----
<footer/>
}
}
Run Code Online (Sandbox Code Playgroud)
这是带有输入字段的屏幕:
import Theme from "../../components/Theme";
import { Input, Button } from "react-native-elements";
export default class ChangePassword extends Component {
constructor(props) {
super(props);
this.state = {
inputs:{
old_password : …Run Code Online (Sandbox Code Playgroud) 升级到RN 0.60后-尝试运行以下命令:
react-native run-android --variant=release
Run Code Online (Sandbox Code Playgroud)
失败,出现错误:
任务':app:packageRelease'的执行失败。工作者提出了2个异常:java.io.UncheckedIOException:java.io.IOException:压缩执行失败。java.lang.OutOfMemoryError
我的解决方案是:
android {dexOptions {javaMaxHeapSize“ 4g”}}
org.gradle.jvmargs = -Xmx4608M
我目前有以下活动,它是在我的应用程序启动时创建的,并在我的 AndroidManifest.xml 中声明为活动:
AndroidManifest.xml:
<activity android:name=".IncomingActivity"></activity>
Run Code Online (Sandbox Code Playgroud)
传入Activity.java:
package com.xyz;
import android.os.Build;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;
public class IncomingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
setShowWhenLocked(true);
setTurnScreenOn(true);
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
setContentView(R.layout.activity_incoming);
}
}
Run Code Online (Sandbox Code Playgroud)
我现在希望能够从 React Native 按需使用此功能。到目前为止,我已经像下面这样重构了它,但是当调用这个本机方法时,我只是得到一个空白的白屏,我认为问题出在这一行:activity.setContentView(mReactRootView);
更新类:
public class UnlockDevice extends ReactContextBaseJavaModule {
@Override
public String getName() {
return "UnlockDevice";
}
private ReactContext mReactContext;
private ReactRootView mReactRootView;
public UnlockDevice(ReactApplicationContext reactContext) { …Run Code Online (Sandbox Code Playgroud)