我在我的 android 应用程序中添加了一个 webbrowser (webview),但是当我例如去一个有呼叫或导航按钮的网站时,比如谷歌或电话簿页面,它只是说无法打开电话:一些号码。如果它是导航按钮,应该打开拨号器或谷歌地图。我该如何处理?请帮忙
代码:
package com.mysoftware.mysoftwareos.launcher;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class PeopleSearchActivity extends Activity implements OnClickListener {
WebView peoplesearchWebView;
EditText peoplesearchEditText;
Button peopleSearchButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.peoplesearch);
//Import views
peoplesearchWebView = (WebView)findViewById(R.id.peoplesearchWebView);
peoplesearchEditText = (EditText)findViewById(R.id.peoplesearchEditText);
peopleSearchButton = (Button)findViewById(R.id.peopleSearchButton);
//Setup onClickListener for the buttons
peopleSearchButton.setOnClickListener(this);
//Setup WebView
peoplesearchWebView.getSettings().setJavaScriptEnabled(false);
peoplesearchWebView.getSettings().setBuiltInZoomControls(false);
peoplesearchWebView.setWebViewClient(new myWebViewClient());
}
public void onClick(View src) {
switch(src.getId()) {
case R.id.peopleSearchButton:
String searchUrl;
searchUrl = ("http://m.gulesider.no/query?search_word=" + peoplesearchEditText.getText().toString() + "&geo_area=&what=mobwp&hpp=10");
peoplesearchWebView.loadUrl(searchUrl);
}
}
public class myWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(String url, WebView view) {
view.loadUrl(url);
return true;
}
}
}