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();
}
});
}
}
代码显示以下错误..
res\layout\Contact_us.xml: Invalid file name: must contain only [a-z0-9_.]
答案 0 :(得分:75)
尝试删除大写字母。 res\layout\contactus.xml
答案 1 :(得分:11)
您需要使用小写字母。您有'C',您必须将其重命名为contact_us.xml。
答案 2 :(得分:9)
将C设为c。使用小写字母,没有符号
答案 3 :(得分:4)
使用小写字母并清理包
答案 4 :(得分:2)
它应该是contactus.xml,您应该按照下面列出的命名约定:
文件名必须仅包含小写的a-z,0-9或_。
only a-z,mind that not capital...and white-space not allowed
name must start with a character.not with a Number(0-9)
name only _ symbol allowed.no other symbol alowed.
答案 5 :(得分:0)
尝试使用小写字母命名xml布局。为我工作 Contact_us.xml将此更改为contact_us.xml