Created
June 29, 2017 17:11
-
-
Save bilijo/842f085fbaefe0902086f6bf8207bfd7 to your computer and use it in GitHub Desktop.
click listener on the ListView, to earthquakeApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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