如何使状态忽略封头?我想改变一下:
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;发布于 2013-09-17 16:31:04
字符串库中有一个名为equalsIgnoreCase()的方法,您可以忽略大写锁。
您还拥有toLowerCase()方法,它将大写锁转换为小写。
发布于 2013-09-17 16:32:21
尝试:
if (Name.toLowerCase().contains(layout.txtName.getText().toString().toLowerCase()))不幸的是,没有containsIgnoreCase方法。
另外,但非主题您可能想:
Name重命名为namehttps://stackoverflow.com/questions/18855094
复制相似问题