React 原生文档提供了一个用 java 编写的Toast 模块示例。
同样的例子在 Kotin 中是什么样子的?
android项目的配置有什么特别的步骤吗?
我想要在 react-native 选择器上使用 style font-size 和 font-family 。我已经在原生 android 上设置了自定义样式。但是在我再次构建 apk 之后没有改变它仍然是相同的字体。
我在 style.xml 上的代码
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
</style>
<style name="SpinnerItem" parent="Theme.AppCompat.Light.NoActionBar">>
<item name="android:fontFamily">CenturyGothicBold</item>
<item name="android:textSize">16dp</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
这里的任何想法/帮助都是关于如何让“npm install --save-dev eslint --verbose”工作的。我不断得到:
Error: EINVAL: invalid argument, read
Run Code Online (Sandbox Code Playgroud)
我已经建立了一个新的 react-native 项目:
react-native init gcLists
E:\gcLists>npm -v
5.5.1
E:\gcLists>yarn -v
1.2.1
E:\gcLists>react-native -v
react-native-cli: 2.0.1
react-native: 0.49.5
npm install --save-dev eslint --verbose
Run Code Online (Sandbox Code Playgroud)
日志的最后一部分:
npm http fetch GET 304 https://registry.npmjs.org/slice-ansi 104ms (from cache)
npm verb correctMkdir D:\Users\greg\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
npm verb lock using D:\Users\greg\AppData\Roaming\npm-cache\_locks\staging-255cd84f0d76b150.lock for E:\gcLists\node_modules\.staging
npm info lifecycle semver@5.4.1~preuninstall: semver@5.4.1
npm info lifecycle semver@5.4.1~uninstall: semver@5.4.1
npm verb unbuild rmStuff semver@5.4.1 from E:\gcLists\node_modules
npm verb unlock done …Run Code Online (Sandbox Code Playgroud) 我正在使用 react-native-tab-view 模块在我的应用程序中实现选项卡。选项卡工作正常,但我希望当用户向下滚动列表时,应使用动画隐藏选项卡栏。
我正在使用的模块链接,即 https://github.com/react-native-community/react-native-tab-view
这是我的代码:-
import React, { Component } from 'react';
import { View, Text, ScrollView, ActivityIndicator } from 'react-native';
import { TabViewAnimated, TabBar, SceneMap } from 'react-native-tab-view';
import styles from './Styles';
// First tab component
const FirstRoute = () => (
<ScrollView>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
<Text>1</Text>
</ScrollView>
);
export default class BookingDetail extends Component {
// default states
state = {
index: 0,
routes: [
{ key: …Run Code Online (Sandbox Code Playgroud) reactjs react-native react-native-scrollview react-native-android react-native-tab-view
我已使用本机 fetch API 登录到我的应用程序。我现在需要加载一个图像,所以我将它加载到一个<WebView>. 是否可以告诉 webview 使用这些 cookie?
当用户选择语言时,我试图在运行时更改我的应用程序的语言。我正在尝试这样做
import I18n from 'react-native-i18n'
onChangeLanguage = () => {
console.log('String before change : >>> ', I18n.t('welcome'))
I18n.locale = 'hi'
console.log('String after change : >>> ', I18n.t('welcome'))
}
Run Code Online (Sandbox Code Playgroud)
在两个日志中,我得到了相同的 string 。我从这里参考。在此参考中,有一个使用 redux 的示例,但我的用例是使用 mobx。如果语言更改了如何重新渲染组件以反映语言更改。
android react-native mobx react-native-android react-native-ios
我正在使用 react-native 版本,0.49.3并且在我的项目目录中创建了一个文件 index.js。它适用于 ios 但当我为 Android 运行它时,它会出错
在任何根目录中都找不到入口文件 index.android.js
我需要在我的 android 文件夹中添加一些东西吗?
我需要为我的 react-native 应用程序实现 websocket 连接。
我的问题是我总是得到:
无法设置WS://www.needseek.com:31337 partyId = “a3e75250-d1a3-11e7-9116-a7b8f75cfbc6” &sessionToken = “eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJ0eUlkIjoiYTNlNzUyNTAtZDFhMy0xMWU3LTkxMTYtYTdiOGY3NWNmYmM2Iiwibm9uY2UiOiIxNTExNTkxNTQyNDE3MDAiLCJpYXQiOjE1MTE1OTE1NDJ9.HVfHRlXbcUZgkTFfL42YGd0LGtCUjnJuQ5ju3S1alOk” 作为默认原点头。
这是我使用的代码:
let wsUrl = 'ws://www.needseek.com:31337?partyId="' + user.profile.partyId + '"&sessionToken="'+ user.sessionToken + '"';
console.log( 'Websocket Url', wsUrl );
var ws = new WebSocket( wsUrl );
ws.onopen = () => {
// connection opened
ws.send('Connection open..');
console.log('Connection open..');
};
ws.onmessage = (e) => {
// a message was received
console.log(e.data);
};
ws.onerror = (e) => {
// an error occurred
console.log(e.message);
};
ws.onclose = (e) => {
// …Run Code Online (Sandbox Code Playgroud) 嘿,我正在尝试创建一个事件,该事件将在键盘出现时触发,但该功能触发了不止一次,我不知道为什么..
import React, { Component } from 'react';
import { Keyboard, Alert, View, TextInput } from 'react-native';
export default class App extends Component {
constructor(props: any) {
super(props);
this.kbDidShowListener = Keyboard.addListener('keyboardDidShow', () => Alert.alert('keyboard is up'));
}
componentWillUnmount() {
this.kbDidShowListener.remove();
}
render() {
return (
<View style={{ marginTop: 30 }}>
<TextInput />
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
这是示例的博览会(您将多次看到警报) https://snack.expo.io/H1DHaIdgM
ps我在Android上工作。
谢谢!
我的 Android react native 对于调试版本工作正常,但是在构建签名发布 apk 之后: cd android && ./gradlew assembleRelease 然后它总是在启动时崩溃。APK 的文件大小看起来与调试文件的大小非常相似(差别不大)。这是来自 logcat 的错误。(我已经检查了关于发布问题的其他 stackoverflow 问题,但找不到解决方案。我也尝试过“gradle clean”构建)。
反应原生版本 0.44
01-17 14:08:13.694 E/UncaughtException: java.lang.RuntimeException: Error calling AppRegistry.runApplication
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)
at java.lang.Thread.run(Thread.java:762)
Caused by: com.facebook.jni.CppException: Could not get BatchedBridge, make sure your bundle is packaged correctly
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:208)
at java.lang.Thread.run(Thread.java:762)
01-17 14:08:13.922 E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: com.challengesolutions.lifeapp, …Run Code Online (Sandbox Code Playgroud) react-native ×10
android ×3
facebook ×1
kotlin ×1
mobx ×1
node.js ×1
npm ×1
npm-install ×1
reactjs ×1