本文介绍了无法在android studio中解析R?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了注册表申请.然而,它运行得很好;它现在显示构建错误.我该如何解决这个问题?

I completed a registration form application. It runs perfectly, however; it is now showing a build error. How can I solve this?

 @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            etusername=(EditText) findViewById(R.id.uname);
            etpassword=(EditText) findViewById(R.id.upassword);
            blogin=(Button) findViewById(R.id.blogin);
            registerlink=(Button) findViewById(R.id.register);
            blogin.setOnClickListener(this);
            registerlink.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
            switch(v.getId()){
                case R.id.register:
                    startActivity(new Intent(this,RegisterActivity.class));
                    break;
                case R.id.blogin:

                    if(etusername.getText().toString().equals("admin") &&

                            etpassword.getText().toString().equals("admin")) {
                        startActivity(new Intent(this,HomeActivity.class));
                    }
                    else {
                        Toast.makeText(getApplicationContext(), "Invalid username/password", Toast.LENGTH_SHORT).show();
                    }

                        break;

            }
        }
    }

推荐答案

通常,您可以通过清理项目,然后重新构建它来修复此错误.

Typically you can fix this error by cleaning your project, and then rebuilding it.

构建 -> 清理项目构建 -> 重建项目

Build -> Clean ProjectBuild -> Rebuild Project

这篇关于无法在android studio中解析R?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:57