So I'm working with a list view trying to get specific activities to open when a certain item is selected. This is the code that I'm working with right now. I know its wrong but am not sure what I need to change it make it work. I think I need an intent and tried a few ideas but did not come up with much. Thanks.
package table.periodic;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class List extends ListActivity{
String[] elements={"actinium", "aluminum", "americium",
"antimony", "argon", "arsenic", "astatine", "barium",
"berkelium", "beryllium", "bismuth", "bohrium", "boron",
"bromine", "cadmium", "calcium", "californium", "carbon",
"cerium", "cesium", "chlorine", "chromium", "cobalt",
"copper", "copernicium", "curium", "darmstadtium", "dubnium",
"dysprosium", "einsteinium", "erbium", "europium", "fermium",
"fluorine", "francium", "gadolinium", "gallium", "germanium",
"gold", "hafnium", "hassium", "helium", "holmium",
"hydrogen", "indium", "iodine", "iridium", "iron",
"krypton", "lanthanum", "lawrencium", "lead", "lithium",
"lutetium", "magnesium", "manganese", "meitnerium", "mendelevium",
"mercury", "molybdenum", "neodymium", "neon", "neptunium",
"nickel", "niobium", "nitrogen", "nobelium", "osmium",
"oxygen", "palladium", "phosphorus", "platinum", "plutonium",
"polonium", "potassium", "praseodymium", "promethium", "protactinium",
"radium", "radon", "rhenium", "rhodium", "roentgenium", "rubidium",
"ruthenium", "rutherfordium", "samarium", "scandium", "seaborgium",
"selenium", "silicon", "silver", "sodium", "strontium", "sulfur",
"tantalum", "technetium", "tellurium", "terbium", "thallium", "thorium",
"thulium", "tin", "titanium", "tungsten", "ununhexium", "ununoctium",
"ununpentium", "ununquadium", "ununseptium", "ununtrium", "uranium",
"vanadium", "xenon", "ytterbium", "yttrium", "zinc", "zirconium"};
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.list);
setListAdapter(new ArrayAdapter<String>(
this, android.R.layout.simple_list_item_1,
elements));
}
public void onListItemClick(ListView parent, View v, int position,
long id){
if ("actinium".equals(elements[position]))
{startActivity(Actinium.class);}
else if ("aluminum".equals(elements[position]))
{startActivity(Aluminum.class);}
}