小编Pin*_* Ng的帖子

React Native android TextInput 无法显示键盘

我在反应原生 textInput 时遇到了一些问题。

在我添加 createBottomTabNavigation 之前,TextInput 工作正常。它在 IOS 上运行良好,但在 Android 上运行良好。我创建了一个示例组件,但问题仍然存在。这里的问题:

  1. 当在 SamplePage 组件上单击 TextInput 字段时,页面只是有点闪烁,键盘后退。

这是我真实 android 设备上的问题图像: react-native android app

这是我的代码:

import React from 'react';
import 'react-native-gesture-handler';
import {
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
  TouchableOpacity,
  TextInput,
} from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { useNavigation } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Ionicons from 'react-native-vector-icons/Ionicons';
import ContextApp from '../../context/contextApp';
import PremiumScreen from './premiumScreen';
import SettingsPage from '../setting/settingsPage';
import ProfileContainer from '../profile/profileContainer'; …
Run Code Online (Sandbox Code Playgroud)

android react-native react-navigation-v5

5
推荐指数
1
解决办法
1384
查看次数

写入本地 json 文件 dart flutter

我正在创建一个允许用户保存小数据的应用程序。我的资产文件夹中有一个 json 文件,我想创建一个可以向其中写入更多 json 数据的应用程序。路径:assets/vault.json

金库.json

[
  {
    "name":"Ash",
    "age":"22",
    "hobby" : "golf"
  },
  {
    "name":"philip",
    "age":"17",
    "hobby" : "fishing"
  },
  {
    "name":"charles",
    "age":"32",
    "hobby" : "drawing"
  }

]
Run Code Online (Sandbox Code Playgroud)

但是我坚持向 json 文件添加更多列表。

在我的 main.dart 中,我创建了 3 个用于输入的文本字段和一个用于触发 writeToFile(arg1,arg2,arg3) 的按钮 onPress。

这是我尝试过的:

void writeToFile(String hobbyy, String agee, String namee) {
  print("Writing to file!");

  Map<String, dynamic> content = new Map();
  content1 = {name: namee};
  content2 = {age: agee};
  content3 = {hobby: hobbyy};

  content.addAll(content1);
  content.addAll(content2);
  content.addAll(content3);


  print(content);  //working fine
}

Future<String> _loadAVaultAsset() async …
Run Code Online (Sandbox Code Playgroud)

json dart flutter

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