首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在android studio中为图片添加URL?

如何在android studio中为图片添加URL?
EN

Stack Overflow用户
提问于 2015-10-09 23:41:42
回答 3查看 8.5K关注 0票数 1

我希望在我的应用程序中,当有人点击图片时,它会用默认浏览器打开。

我到处都找过了,但没有一种方法能帮到我。

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".Home_Activity"
android:background="#FF0000">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/AppTitleimage1"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:src="@mipmap/fra"
    android:contentDescription="@string/AppTitleImageS"
    android:autoLink="web"
    android:clickable="true" />

如何添加指向在默认浏览器中打开的图像的链接

谢谢

所以我发现了这个:

代码语言:javascript
复制
ImageView imgLink=(ImageView)findViewById(R.id.weblink);
    imgLink.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent link=new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
            startActivity(link);    
        }
    });

但是当我将它粘贴到我的java类中时,它会说:

“无法解析方法'findViewById'(?)和”无法解析符号'weblink‘和“无法解析方法startActivity(android.content.intent)”

我的问题不同,答案也不起作用。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33042292

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档