所以我试图为我的应用程序创建一个登录页面,我正在 Android Studio 上实现它,但它收到一个错误,提示无法解析 setContentView 中的符号。几个小时以来,我一直在振作起来,但我仍然无法弄清楚它有什么问题。setContentView(R.layout.activity_main); 就在这一行,它说 activity_main 不能解析为变量,即使我命名我的 xml 文件与它完全相同。这是我的代码,
package com.example.tieulyphidep.treasurehunters;
import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.R;
public class login extends ActionBarActivity implements View.OnClickListener{
Button bLoggin,buttonSignup;
EditText EditTextUserName, EditTextPassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bLoggin = (Button) findViewById(R.id.buttonLogin);
buttonSignup = (Button) findViewById(R.id.buttonSignup);
EditTextUserName =(EditText) findViewById(R.id.EditTextUserName);
EditTextPassword =(EditText) findViewById(R.id.EditTextPassword);
buttonLogin.setOnClickListener(this);
buttonSignup.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.buttonLogin:
break;
case R.id.buttonSignup:
startActivity(new Intent(this, register.class));
break;
}
}
}