如何ImageView的链接到网页? [英] How can ImageView link to web page?

查看:144
本文介绍了如何ImageView的链接到网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能作出的ImageView链接到一个网页,这样当用户点击图片,它需要他们的网页?

is it possible to make an imageview link to a web page such that when user taps on the image, it takes them to a web page?

推荐答案

只需添加一个点击监听器的影像打开一个网址:

Just add a click listener to the image to open an URL:

ImageView img = (ImageView)findViewById(R.id.foo_bar);
img.setOnClickListener(new View.OnClickListener(){
    public void onClick(View v){
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.setData(Uri.parse("http://casidiablo.net"));
        startActivity(intent);
    }
});

这篇关于如何ImageView的链接到网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆