小编Gus*_*ndo的帖子

启用时更改一种按钮的颜色

所以当我点击一个心形按钮时,我想用心形按钮列出一个清单。

我只希望一个按钮更改颜色。并保存当前按钮的颜色状态。

我的问题是,当我点击一个心脏按钮时,所有按钮都会更改颜色。

屏幕截图: 在此处输入图片说明

这是我的代码

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  Button,
} from 'react-native';

import { ListItem } from 'react-native-elements'
import { Icon } from 'react-native-elements'
import Data from './src/data/sampledata.json';

export default class App extends Component<Props> {
  constructor(props) {
    super(props);

    this.state = {
      buttonColor: '#979797', // default button color goes here, grey is default
    };
  }

  onButtonPress = () => {
    if(this.state.buttonColor=='#ff002b')
    {
      this.setState({ buttonColor: '#979797' }) // grey
    }
    else {
      this.setState({ …
Run Code Online (Sandbox Code Playgroud)

react-native

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

字符串上的自定义大写

嗨,我试图制作一个程序,将字符串中的单词修改为大写单词.

大写单词在这样的标签中:

the <upcase>weather</upcase> is very <upcase>hot</upcase>
Run Code Online (Sandbox Code Playgroud)

结果 :

the WEATHER is very HOT
Run Code Online (Sandbox Code Playgroud)

我的代码是这样的:

string upKey = "<upcase>";
string lowKey = "</upcase>";


string quote = "the lazy <upcase>fox jump over</upcase> the dog <upcase> something here </upcase>";
        int index = quote.IndexOf(upKey);
        int indexEnd = quote.IndexOf(lowKey);


       while(index!=-1)
        { 

        for (int a = 0; a < index; a++)
        {
            Console.Write(quote[a]);
        }

        string upperQuote = "";

        for (int b = index + 8; b < indexEnd; b++)
        {

            upperQuote += quote[b];
        }

        upperQuote …
Run Code Online (Sandbox Code Playgroud)

c#

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

标签 统计

c# ×1

react-native ×1