水库\布局\ Contact_us.xml:无效的文件名:必须只包含[A-Z0-9 _]文件名、水库、布局、Contact_us

2023-09-05 00:16:06 作者:开奔驰捡垃圾

 公共类主要的扩展活动{

    EditText上的用户名,密码1;
    钮子;
    字符串的uname,通过;

    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);

        分=(按钮)findViewById(R.id.btn_submit);
        sub.setOnClickListener(新View.OnClickListener(){

            @覆盖
            公共无效的onClick(视图v){

                用户名=(EditText上)findViewById(R.id.uname);
                密码1 =(EditText上)findViewById(R.id.editText2);
                。的uname =(字符串)username.getText()的toString();
                通过=(字符串)password1.getText()的toString()。

                如果(uname.equalsIgnoreCase(的uname))
                    如果(pass.equalsIgnoreCase(通行证))
                        Toast.makeText(main.this,用户验证,Toast.LENGTH_LONG).show();
                    其他
                        Toast.makeText(main.this,密码无效,Toast.LENGTH_LONG).show();
                其他
                    Toast.makeText(main.this,用户或密码无效,Toast.LENGTH_LONG).show();
            }
        });
    }
}
 

code显示下面的错误..

 水库\布局\ Contact_us.xml:无效的文件名:必须只包含[A-Z0-9 _]
 

解决方案

尝试删除大写字母。 水库\布局\ contactus.xml

public class main extends Activity {

    EditText username,password1;
    Button sub;
    String uname,pass;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        sub = (Button) findViewById(R.id.btn_submit);
        sub.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                username = (EditText) findViewById(R.id.uname);
                password1 = (EditText) findViewById(R.id.editText2);
                uname = (String) username.getText().toString();
                pass = (String) password1.getText().toString();

                if (uname.equalsIgnoreCase("uname"))
                    if (pass.equalsIgnoreCase("pass"))
                        Toast.makeText(main.this, "user is authenticated", Toast.LENGTH_LONG).show();
                    else
                        Toast.makeText(main.this, "Password Invalid", Toast.LENGTH_LONG).show();
                else
                    Toast.makeText(main.this, "User or Password Invalid", Toast.LENGTH_LONG).show();
            }
        });
    }
}
idea中创建xml文件无法识别,显示成普通文本的解决方法

code showing the following error..

res\layout\Contact_us.xml: Invalid file name: must contain only [a-z0-9_.]

解决方案

Try removing the capital letter. res\layout\contactus.xml