gpt4 book ai didi

java - 使条件忽略大写锁定?

转载 作者:行者123 更新时间:2023-11-29 03:29:47 26 4
gpt4 key购买 nike

如何让条件忽略大写锁定?我想改变:

if ( Name.contains ( layout.txtName.getText ().toString () ) )

并让它忽略大写字母。

case R.id.Contane:
if (Name.contains(layout.txtName.getText().toString()))
{
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);

alert.setTitle("this is the first resulet for the name that you typed");

alert.setMessage("The contact "+Name+" was found in this phone... yaah");

alert.setPositiveButton("ok",new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialogInterface, int i)
{


}

});
alert.show();
Found = true;
break;

最佳答案

尝试toLowerCase()

if ( Name.toLowerCase().contains ( layout.txtName.getText ().toString ().toLowerCase()))

示例:

if("Abc".toLowerCase().contains("a".toLowerCase()))
System.out.print("Success");

输出:

Success

关于java - 使条件忽略大写锁定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18855094/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com