我正在通过 xamarin 开发一个应用程序,并且使用按钮来检查注册字段。
Button sendToRegisterButton = (Button)FindViewById(Resource.Id.registerbtn);
sendToRegisterButton.Touch += delegate { CheckFields(); };
Run Code Online (Sandbox Code Playgroud)
因此,当触摸按钮时,我会检查布尔值touched以查看按钮是否已被按下。
如果通过,我将感动设置为真if(!touched)。我让代码运行,并在 if 语句末尾再次将 touch 设置为 false。现在,当我对此进行测试并按下手机上的注册按钮时,检查字段功能仍然会被多次调用。
相关代码:
private void CheckFields()
{
if (!touched)
{
touched = true;
//Rest of code here... checking the username and password fields etc
touched = false;
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:我尝试禁用该按钮并随后重新启用它,不幸的是没有工作
private void CheckFields()
{
sendToRegisterButton.Enabled = false;
//Rest of code here... checking the username and password fields etc
sendToRegisterButton.Enabled = true;
}
Run Code Online (Sandbox Code Playgroud)
EDIT2:既然人们问了,这是全班同学
using System;
using System.Collections.Generic;
using …Run Code Online (Sandbox Code Playgroud) 我一直在尝试制作一个简单的测试机器人(只是一个意图,具有三个基于文本的不同响应),并将其与我的亚马逊回声挂钩,以进行概念验证。
我在集成的亚马逊方面遇到了麻烦。这是我的问题:
我希望我的机器人对alexa所做的一切就是识别我所说的内容并通过简单的文本答案进行回复...
谢谢你的协助!
我有一个数组,有5个字符串值兴奋,快乐,中立,悲伤,愤怒
我使用ngClass和ngFor来简化html,所以我不必为每个值重复5x.
问题是ngClass语句非常笨重,我找不到合适的方法来简化它.有什么方法可以缩短它吗?
<mat-icon *ngFor="let smiley of smileys" svgIcon="emote_{{smiley}}"
[ngClass]="{ happy: smiley === 'happy', sad: smiley === 'sad', neutral: smiley === 'neutral', angry: smiley === 'angry', excited: smiley === 'excited'}" (click)="selected(smiley, $event)"></mat-icon>
Run Code Online (Sandbox Code Playgroud)
先感谢您!
amazon ×1
amazon-echo ×1
angular ×1
c# ×1
delegates ×1
events ×1
integration ×1
ng-class ×1
ngfor ×1
typescript ×1
xamarin ×1