Skip to content

Instantly share code, notes, and snippets.

@bilijo
Created June 29, 2017 17:11
Show Gist options
  • Save bilijo/842f085fbaefe0902086f6bf8207bfd7 to your computer and use it in GitHub Desktop.
Save bilijo/842f085fbaefe0902086f6bf8207bfd7 to your computer and use it in GitHub Desktop.
click listener on the ListView, to earthquakeApp
// Set an item click listener on the ListView, which sends an intent to a web browser
// to open a website with more information about the selected earthquake.
earthquakeListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
// Find the current earthquake that was clicked on
EarthQuakeData currentEarthQuakeData = mAdapter.getItem(position);
// Convert the String URL into a URI object (to pass into the Intent constructor)
Uri earthquakeUri = Uri.parse(currentEarthQuakeData.getUrl());
// Create a new intent to view the earthquake URI
Intent websiteIntent = new Intent(Intent.ACTION_VIEW, earthquakeUri);
// Send the intent to launch a new activity
startActivity(websiteIntent);
}
}); */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment