图片超链接就是 点击图片可以跳转 主要使用的是隐式意图的跳转来实现,主要的实现代码如下:
布局中的实现代码
<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"
tools:context="com.example.image.MainActivity" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="67dp"
android:onClick="image"
android:layout_marginTop="78dp"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
主类中的实现代码
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void image(View v){
Intent it=new Intent();
it.setAction(Intent.ACTION_VIEW);
it.addCategory(Intent.CATEGORY_BROWSABLE);
it.setData(Uri.parse("http://www.baidu.com"));
startActivity(it);
}
}
贴上上面的代码 就能实现图片的超链接了 快行动吧!