我希望在我的应用程序中,当有人点击图片时,它会用默认浏览器打开。
我到处都找过了,但没有一种方法能帮到我。
<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" />
如何添加指向在默认浏览器中打开的图像的链接
谢谢
所以我发现了这个:
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)”
我的问题不同,答案也不起作用。
https://stackoverflow.com/questions/33042292
复制相似问题