Allen Rufolo
Allen Rufolo

Reputation: 1202

Change Related XML File Android Studio Java Class

I'm new to Android development, and I'm having an issue where my RegistrationActivity Class is essentially pointing to the wrong XML file.

This is the error in logcat:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference at arufolo.myapp.RegistrationActivity.onCreate(RegistrationActivity.java:45)

I found that the error is caused by the following:

When I go to my Registration class and click the little XML icon next to the class name, it shows that the related XML file is the login.xml (My Login Screen)... Instead, I want this to show registration.xml. How do I do this?

Upvotes: 1

Views: 5993

Answers (1)

yole
yole

Reputation: 97178

Please make sure that your Registration class uses the correct layout ID as the parameter to setContentView(). See the documentation for more information.

Upvotes: 5

Related Questions