小编Sag*_*ada的帖子

使用不变性助手将新对象推送到特定索引

我尝试这样做:

 const rowObj = {key: value};
    const rowIndex = 2;

    this.setState({ 
          data: update(this.state.data, 
              { [rowIndex] : { $push : [rowObj] } }
          ) 
    })
Run Code Online (Sandbox Code Playgroud)

但是,它会抛出这样的错误:

Uncaught Error: update(): expected target of $push to be an array; got undefined.
Run Code Online (Sandbox Code Playgroud)

reactjs react-native immutability-helper

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

BottomNavigationView没有显示在我的活动中

我正在使用此链接实现BottomNavigationView 我逐步实现了所有内容,但我的导航视图未在屏幕底部显示.

这就是我所做的.

public class MainActivity extends AppCompatActivity implements ActivityCompat.OnRequestPermissionsResultCallback {

    Intent intent = null;
    BottomNavigationView navigationView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        navigationView = (BottomNavigationView) findViewById(R.id.navigation); 

        navigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {

                int id = item.getItemId();
                if(id == R.id.program){
                    intent = new Intent(MainActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }
                if(id == R.id.access){
                    try {
                        manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                        if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                            Intent myIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                            startActivity(myIntent);
                            overridePendingTransition(R.anim.push_up_in,
                                    R.anim.push_up_out);
                        } else {
                            intent …
Run Code Online (Sandbox Code Playgroud)

android bottom-type material-design

4
推荐指数
1
解决办法
9191
查看次数

react-native scrollview不滚动

我似乎无法弄清楚为什么Android应用程序中的屏幕在Android仿真器中根本无法滚动。这是我的代码:

import React, { Component } from 'react';
import Dimensions from 'Dimensions';

import {
  Text,
  ScrollView,
  View,
  TouchableHighlight,
  StyleSheet
} from 'react-native';


const win = Dimensions.get('window');

class DeficiencyItem extends Component {

    render() {
        const touchable = {
                width:win.width/2-20,
                height:230,
                backgroundColor:'red',
              };
        return (
            <TouchableHighlight style={touchable}>
                <View>
                    <Text>Item Here</Text>
                </View>
            </TouchableHighlight>
        );
  }
}

export default class Items extends Component {
  static navigationOptions = {title:'hey'};

    constructor(props)
    {
        super(props);
    }

    render() {

        let deficiencies = [];
        for(let x = 0; x<12;x++)
        { …
Run Code Online (Sandbox Code Playgroud)

android scrollview react-native

4
推荐指数
1
解决办法
3100
查看次数

比较时间戳时 Firestore 查询问题

我在 Firestore 中有数据,并且正在比较其中的时间对象。

当我使用其他对象(如"ref" and "title"查询)查询时,会成功返回一些数据,但随着时间的推移,它不会返回任何内容。

在此输入图像描述

String dateString = "9-26-2018";
Run Code Online (Sandbox Code Playgroud)

我将此日期转换为timestamp并传入查询:

Timestamp timestamp = new Timestamp(dateString);

DateFormat df = DateFormat.getDateTimeInstance();
df.setTimeZone(TimeZone.getTimeZone("UTC"));
Date utcTime = new Date(df.format(date));

System.out.println("MyDates >>" +utcTime + " >> "+ timestamp.toDate());

CollectionReference ref = db.collection("news");
Query newsQuery = ref.whereEqualTo("time", utcTime );

mNewsList.clear();
newsQuery.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                @Override
                public void onComplete(@NonNull Task<QuerySnapshot> task) {
                    if (task.isSuccessful()) {
                        System.out.println("DocumentData >> " + task.getResult().size());
                        for (QueryDocumentSnapshot document : task.getResult()) {
                            News news = document.toObject(News.class);
                            mNewsList.add(news);
                        }
                        // …
Run Code Online (Sandbox Code Playgroud)

java android firebase google-cloud-firestore

4
推荐指数
1
解决办法
2944
查看次数

在React中,本机'adb'不被识别为内部和外部命令

我试图在环境变量中设置路径,但是它不起作用。

出现如下错误:无法将'adb'识别为内部或外部命令,可操作程序或批处理文件。启动应用程序(C:\ Users \ Administrator \ AppData \ Local \ Android \ Sdk / platform-tool s / adb shell am start -n com.demo / com.demo.MainActivity ...开始:目的{cmp = com.demo / .MainActivity}

android adb android-sdk-tools react-native

3
推荐指数
1
解决办法
7534
查看次数