我想使用AlertDialog.Builder创建一个启动画面,一个自定义视图和一个计时器.
我正在使用Xamarin.Android - 我似乎没有'dismiss'方法,我可以称之为'dispose'但是alertDialog视图没有关闭.
示例代码如下:
public class SplashDialog
{
private readonly AlertDialog.Builder _alert;
private readonly View _view;
public SplashDialog(Context context)
{
_alert = new AlertDialog.Builder(context);
var layoutInflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
_view = layoutInflater.Inflate(Resource.Layout.splash, null);
_alert.SetView(_view);
}
public void Show()
{
_alert.Show();
/*
new Thread(() =>
{
Thread.Sleep(3000);
_view.Dispose();
_alert.Dispose();
}).Start();
* */
new Handler().PostDelayed(() =>
{
_view.Dispose();
_alert.Dispose();
}, 3000);
}
}
Run Code Online (Sandbox Code Playgroud) 鉴于文本:
This is a #tag and this is another #love@irc.oftc.net and more text.
Run Code Online (Sandbox Code Playgroud)
我想匹配以哈希开头并以空格字符结尾的单词(我不想为 指定特定模式#love@irc.oftc.net
)。
我不能使用lookarounds
,也不想使用\b
.
我试过#.*\b
, #.*\s
,它会比我要求的更匹配。我猜它*
也会匹配空格,所以最后一次检查被忽略。
我使用https://regexr.com/进行测试。
我想隐藏SingleChildScrollView
带有焦点的滚动键盘TextFormField
。我NotificationListener<ScrollNotification>
在的顶部添加SingleChildScrollView
,并收听ScrollStartNotification
。然后FocusScope.of(context).requestFocus(FocusNode())
,我打电话隐藏键盘。
当TextFormField
位于屏幕底部时,会出现问题。当我单击它并获得焦点时,键盘出现并向上移动SingleChildScrollView
,这再次触发ScrollStartNotification
并隐藏了键盘。
在下面的示例中,为什么myList
null
没有向构造函数传递参数?
我在类中将其声明为空(可增长)列表。
class MyListClass {
List myList = [];
MyListClass({this.myList});
}
void main() {
final obj = MyListClass();
assert(obj.myList != null);
}
Run Code Online (Sandbox Code Playgroud)
传递可选列表但默认为空列表的最佳方法是什么?
我知道你可以执行以下操作,但也许有更好的方法?
MyListClass({this.myList}) {
this.myList ??= [];
}
Run Code Online (Sandbox Code Playgroud)
UDATE:这是预期的行为,null
如果没有根据this指定值,则这是默认行为。