Skip to content
Advertisement

Intent with multiple if statements

I am learning the concept of Intents and the application I am working on crashes when I try to go from any other intent that’s not “Arabica” intent, the intent object is fired on onItemSelectedListener on a spinner. I want to make it so that when the user selects the other options on the spinner it will execute that intent and go to the other activity which displays a code of text for my coffee application.

Below is the code:

JavaScript

}

Here is the xml:

JavaScript

Here is also my manifest:

JavaScript

Finally here is the error log:

JavaScript

I didn’t implement a setOnCLickListener for the button but i dont think that’s the issue here is my onCreate though with all my Liberica code:

JavaScript

}

and my xml:

JavaScript

Advertisement

Answer

The reason is just a typo. In the Liberica Class change this line:

JavaScript

To this:

JavaScript

Because the actual id of the button is back2 not back as you can see:

JavaScript

Also make sure that setContentView(R.layout.activity_main); In the Liberica Class is pointing to the Liberica XML layout file for example if it is called activity_liberica.xml set it to:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement