如何让条件忽略大写锁定?我想改变:
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/