Rotemash
Rotemash

Reputation: 9

how to click on listview item that will tranfer me to website url?

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

Answers (2)

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

williamj949
williamj949

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

Related Questions