android自定义标签需要使用到的类有webviewClient这个类;我们要做的是重写这里面的一个方法;这个重写的方法里有一个参数是url;我们就要用到url;

我在这里需要用到有activity;layout;html文件;在javascript调用android打电话;还需要添加打电话权限哦;

layout文件主要就是一个webview控件;

java代码;如下;

package com.tarena.chat.view;import com.tarena.chat.R;import android.app.Activity;import android.content.Intent;import android.net.Uri;import android.os.Bundle;import android.webkit.WebView;import android.webkit.WebViewClient;public class HelpActivity extends Activity{    private WebView webview;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.help_layout);        webview=(WebView)findViewById(R.id.gridView1);        webview.loadUrl("file:///android_asset/help.html");        webview=new WebView(getApplicationContext());        webview.setWebViewClient(new WebViewClient(){            @Override            public boolean shouldOverrideUrlLoading(WebView view, String url) {                if (url.contains("tarena/tell:")) {                    String index="tarena/tell:";                    String phone=url.substring(index.indexOf("tarena/tell".length()));                    Intent intent=new Intent(Intent.ACTION_CALL,Uri.parse("tell"+phone));                    startActivity(intent);                }                return super.shouldOverrideUrlLoading(view, url);            }        });    }}


html文件如下;我在这里是将html文件放到了asset目录下;

    

欢迎使用天天聊天软件

这个软件使用很方便

这个软件使用很方便

这个软件使用很方便

这个软件使用很方便

这个软件使用很方便

这个软件使用很方便

联系我们 访问官方博客

ok啦;


更多相关文章

  1. Myeclipse添加android开发插件
  2. Now in Android:02 - 欢迎使用 Android(安卓)Studio 4.0 !
  3. android代码混淆
  4. Android(安卓)中Ninja 简介
  5. 写在20110626:NDK、JNI
  6. Android(安卓)怎么样使用shape
  7. 箭头函数的基础使用
  8. NPM 和webpack 的基础使用
  9. Python list sort方法的具体使用

随机推荐

  1. Android轩辕剑之ActionBar之三
  2. Android平台输入法的生命周期
  3. Android(安卓)JNI 篇 - JNI回调的三种方
  4. Android(安卓)获得Url、Uri字符串后面拼
  5. 在Eclipse上搭建Android(安卓)2.3环境
  6. Android(安卓)6.0 新特性之 RunTime Perm
  7. android 桌面小组件小记
  8. Android后台服务概述
  9. Activity 的四种启动模式(launchMode)
  10. Android(安卓)SurfaceFlinger之CS架构