The answer to AndroidChen didn't work for me at all, but I was looking for the provided link ( http://code.google.com/p/android/issues/detail?id=7189 ) and I found the following class, it works fine (Android Froyo on HTC Bravo), not just text, but all buttons, redirects, etc., everything works fine: D
class LiveWebView extends WebView { Context mContext; public LiveWebView(Context context, String URL) { super(context); mContext = context; setWebViewClient(URL); } @Override public boolean onCheckIsTextEditor() { return true; } @SuppressLint("SetJavaScriptEnabled") boolean setWebViewClient(String URL) { setScrollBarStyle(SCROLLBARS_INSIDE_OVERLAY); setFocusable(true); setFocusableInTouchMode(true); requestFocus(View.FOCUS_DOWN); WebSettings webSettings = getSettings(); webSettings.setSavePassword(false); webSettings.setSaveFormData(false); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(false); webSettings.setUseWideViewPort(false); setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); this.setWebViewClient(new WebViewClient() { ProgressDialog dialog = new ProgressDialog(mContext); @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { loadUrl(url); return true; } public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Toast.makeText(mContext, "Oh no! " + description, Toast.LENGTH_SHORT).show(); } public void onPageStarted(WebView view, String url, Bitmap favicon) { if (dialog != null) { dialog.setMessage("Loading..."); dialog.setIndeterminate(true); dialog.setCancelable(true); dialog.show(); } } public void onPageFinished(WebView view, String url) { if (dialog != null) { dialog.cancel(); } } }); this.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) {
and then, to create a webview in a dialog box, I wrote this code
AlertDialog.Builder alert = new AlertDialog.Builder(M_PaymentOptions.this); alert.setNegativeButton("Back to Payment Options", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) {} }); alert.setTitle("BarclayCard Payment"); LiveWebView liveWevViewObject = new LiveWebView(M_PaymentOptions.this, redirecturl); alert.setView(liveWevViewObject); alert.show();
Dv_MH Apr 08 '13 at 18:18 2013-04-08 18:18
source share