如果 Textview 为 null 或为空 [英] If Textview is null or empty
本文介绍了如果 Textview 为 null 或为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 xamarin 项目的初学者.所以请耐心等待我.我想检查 textview 是否为空或为空.我正在使用此代码,但它不起作用.
I'm beginner in xamarin's projects. So please be patient with me. Ι want to check if textview is null or empty.I'm using this code but it doesnt work.
TextView textview2 = FindViewById<TextView>(Resource.Id.textView2);
TextView textview1 = FindViewById<TextView>(Resource.Id.textView1);
if (textview1 != null)
{
textview2.Text = "123";
}
else
{
}
推荐答案
改为
if (textview1.Text != null &&textview1.Text.equals("")) { ... }
if (textview1.Text != null && textview1.Text.equals("")) { ... }
因为 textview1 本身就是不为空的实际 textview 对象.
because textview1 alone is the actual textview object which is not null.
这篇关于如果 Textview 为 null 或为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文