ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,tvShows);
final ListView theListView = (ListView) findViewById(R.id.theListView1); theListView.setAdapter(adapter);
theListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int itemPosition = position; String value = (String) theListView.getItemAtPosition(position);
switch (value){ case "southPark": Intent southparkScreen = new Intent(MainActivity.this, SouthPark.class); MainActivity.this.startActivity(southparkScreen); break; case "naruto": Intent narutoscreen = new Intent(MainActivity.this, Naruto.class); MainActivity.this.startActivity(narutoscreen); break; case "simpsons": Intent simpsonsScreen = new Intent(MainActivity.this, Simpsons.class); MainActivity.this.startActivity(simpsonsScreen); break;
case "americandad": Intent americandadscreen = new Intent(MainActivity.this, AmericanDad.class); MainActivity.this.startActivity(americandadscreen); break;
}
}
});
}
SouthPark.java
public class SouthPark extends AppCompatActivity {