在WebView中插入按钮播放/暂停

时间:2014-10-13 12:44:28

标签: android webviewclient

点击时,活动中有一个按钮,打开时会提示来自Internet的AlertDialog网址。如何在WebView中插入按钮播放/暂停,或将我的布局文件与现有代码链接? 请帮忙,我是这个新手

public void ShowTrack(final String smetaout,String stitleout)
{   
    AlertDialog.Builder alert = new AlertDialog.Builder(this); 
    alert.setTitle(stitleout);

    WebView wv = new WebView(this);
    //setContentView(R.layout.track_view);
    //wv = (WebView) findViewById(R.id.trackView);

    Log.d("My Webview", "ShowTrack");

    wv.getSettings().setJavaScriptEnabled(true);

    wv.loadUrl(smetaout);
    wv.setWebViewClient(new WebViewClient()
    {           
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url)
        {    
            if (!loadingFinished)
            {
                redirect = true;
            }

            loadingFinished = false;

            view.loadUrl(url);
            Log.d("shouldOverrideUrlLoading", url);
            Uri myUri = Uri.parse(url);
            context = getApplicationContext();
            MediaService.releaseMP();
            MediaService.initT(context, myUri);
            MediaService.startT();
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url)
        {
            if(!redirect)
            {
                loadingFinished = true;
                Log.d("onPageFinished", "loadingFinished = true;");
            }

            if(loadingFinished && !redirect)
            {
                //HIDE LOADING IT HAS FINISHED
            }
            else
            {
                redirect = false; 
            }
        }
    });

    alert.setView(wv);
    alert.setNegativeButton("Close", new DialogInterface.OnClickListener()
    {
        @Override
        public void onClick(DialogInterface dialog, int id)
        {
            MediaService.stopT();
            dialog.dismiss();
        }
    });

    alert.show();
}

0 个答案:

没有答案