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

标签 java android

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

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/

相关文章:

java - 在扩展 JFrame 的类中的另一个 JFrame 上绘制一条线

java - org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'XXX'

android - Android 中的 onTouch 和 onTouchEvent 方法

java - Clojure:定义模式中的 HashMap 和数组映射类型冲突

java - 防止 API 中的 System.exit()

Android 服务器-客户端应用程序 session 问题

android - 输出程序时出现 Gradle 构建错误

android - 新的 Google Drive Rest API,依赖太多

java - 使用 java 7u45 启动已签名的小程序时出现的问题

android - 统一社交API