I have a listview with items inside each cell. I am able to get Toast alerts but what I would like it to do is to start a new activity with the content of the cell being displayed with a textview. Is this even possible? Here is my code for reference:
public class Activity extends ListActivity implements OnItemClickListener {
ArrayList<HashMap<String,String>> gameCollection = new ArrayList<HashMap<String, String>>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView listView=getListView();
listView.setOnItemClickListener(this);
//Populate view with data
gameCollection.add(displayVideoGame("PlayStation","FIFA 14"));
gameCollection.add(displayVideoGame("PlayStation","Thief"));
gameCollection.add(displayVideoGame("PlayStation","Watch Dogs"));
gameCollection.add(displayVideoGame("PlayStation","Battlefield 4"));
gameCollection.add(displayVideoGame("PlayStation","Second Sun"));
gameCollection.add(displayVideoGame("PlayStation","Mario Bros"));
//Calling the Simple Adapter calling gameCollection List and setting the predefined layout
SimpleAdapter adapter = new SimpleAdapter(this,this.gameCollection, android.R.layout.simple_list_item_1, new String[] {"PlayStation"},new int[] {android.R.id.text1});
//set adapter to collection
System.out.println(gameCollection);
setListAdapter(adapter);
}
//Create Private Method - Returns HashMap with key-value pairs
private HashMap<String, String> displayVideoGame(String key, String value)
{
HashMap<String, String> videoGameHashMap = new HashMap<String, String>();
videoGameHashMap.put(key, value);
return videoGameHashMap;
}
public void onItemClick(AdapterView<?> adapter, View arg1, int position, long arg3)
{
String item=adapter.getItemAtPosition(position).toString();
Toast.makeText(Activity.this, "You Click on:"+item, Toast.LENGTH_SHORT).show();
}