我想在我的應用程序中,當有人點擊圖像時,它會打開默認瀏覽器。如何將URL添加到android studio中的圖像?
我到處搜索,但沒有方法可以幫助我。
<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’(?) 和 」無法解析符號‘網站鏈接’ 和 「無法解析方法startActivity(android.content.intent)
我的問題是不同的,這個問題的答案是不工作
複製:http://stackoverflow.com/questions/8356655/imageview-autolink – yongsunCN