Reputation: 9
I have a listview with items inside. can anybody please help me to write a code that when I click on an item it will transfer me to website , for EX : a list of birds when I click on a bird it will give me the color of the bird. thanks,
Upvotes: 0
Views: 65
Reputation: 7936
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Uri url = Uri.parse("your link");
Intent intent = new Intent(Intent.ACTION_VIEW, url);
startActivity(intent);
}
});
Upvotes: 0
Reputation: 11316
protected void onListItemClick(ListView l, View v, int position, long id)
{
super.onListItemClick(l,v,position,id);
Uri uriUrl = Uri.parse("your link");
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
startActivity(launchBrowser);
}
Add Internet permission to manifest
Upvotes: 1