繁体   English   中英

连接到firebase时在android studio中找不到符号

[英]cannot find symbol in android studio while connecting to firebase

当我尝试将我的应用程序连接到数据库时,它显示了找不到符号的错误。

error: cannot find symbol
                String ownerName = ownerName.getEditText().getText().toString();
                                            ^
  symbol:   method getEditText()
  location: variable ownerName of type String

下面是我的代码

public class merchantRegistrationForm extends AppCompatActivity implements View.OnClickListener {
    EditText ownerName, phoneNumber, emailId, password, cnfPassword;

    DatabaseReference databaseReference;
    FirebaseAuth firebaseAuth;
    FirebaseDatabase rootNode;



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

        ownerName = findViewById(R.id.ownerName);
        phoneNumber = findViewById(R.id.ownerPhoneNumber);
        emailId = findViewById(R.id.ownerEmailId);
        password =findViewById(R.id.password);
        cnfPassword =findViewById(R.id.confirmPassword);

        Button goNext;
        goNext = findViewById(R.id.nextToBusinessSelector);
        goNext.setOnClickListener(this);

        databaseReference = FirebaseDatabase.getInstance().getReference("merchant Signup");

        goNext.setOnClickListener(new View.OnClickListener() {
            @Override


            public void onClick(View v) {
                rootNode = FirebaseDatabase.getInstance();
                databaseReference = rootNode.getReference();
                String ownerName = ownerName.getEditText().getText().toString();
                String phoneNumber = phoneNumber.getEditText().getText().toString();
                String emailId = emailId.getEditText().getText().toString();
                String password = password.getEditText().getText().toString();
                String cnfPassword = cnfPassword.getEditText().getText().toString();
                merchantsignup helperclass = new merchantsignup(ownerName, phoneNumber,emailId, password, cnfPassword);

                databaseReference.setValue("hello");

            }
        });


        Intent intent = new Intent(merchantRegistrationForm.this, salonDetails.class);
        startActivity(intent);
        Toast.makeText(this, "Few Steps more", Toast.LENGTH_LONG).show();

    }



    @Override
    public void onClick(View view) {

    }
}

您的代码令人困惑,因为您最初将ownerName声明为 EditText:

EditText ownerName;

但随后将其重新定义为字符串:

String ownerName = ownerName.getEditText().getText().toString();

错误消息告诉您 String 对象上没有getEditText()方法。 也许您想为字符串变量使用不同的名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM