I can’t start a ‘New Activity’ when each item is clicked, I’m using a condition such as if-else,
if (item.equals("Aerosol")) {
startActivity(new Intent(Search.this, Aerosol.class));
startActivity(intent);
I use this there is nothing wrong but I can’t go to the next class.
In order to start an intent, declare the Intent in the AndroidManifest as this:
where
.MainActivityis the name of the class,com.example.packageis your package name,EXCLASSis whatever you would like it to be but remember what you named it.For every new activity you would like to start, you should redeclare a new
<activity> />in the AndroidManifest, with the same pacakage name, a new word instead ofEXCLASS, and theandroid:name=".MainActivity"should change to be an exact copy of the class name with a decimal placed in the front. This should be placed after the<application> />declaration so it looks like this:In your class, MainActivity in my example, you would declare
startActivity(new Intent("com.example.package.EXCLASS"));wherecom.example.packageis your package name, andEXCLASSis whatever your declared it to be in the AndroidManifest.The ending result would be:
Hope this helped!