显示/隐藏的WebView问题问题、WebView

2023-09-06 04:31:21 作者:夜炙至尊

我在那有同样的看法一组按钮和一个Web视图(已废弃的),当应用程序启动时,它显示了只能从在点击按钮的应用程序的工作显示了Web视图并加载网址(其中按钮被设置为飘布局),其中包含一个闪光媒体播放器和一个按钮,当是点击它使web视图无形再次显示包含的按钮,以便能够选择不同的第一布局网站,问题是,当Web视图变为无形的闪存媒体播放器保持停留在屏幕和盖帽上的按钮,我该怎么解决这个问题?这将是确定的,如果媒体播放器留下的按钮,但我无法找到答案,任何帮助将是非常美联社preciated,谢谢你。

I'm working in an application that has in the same view a set of buttons and a web view(GONE), when the app starts it shows only the buttons from where at a click it shows the web view and loads a url (the layout where the buttons are is set to GONE) that contains a flash media player and a single button that when is click it makes the web view invisible again and shows the first layout that contains the buttons to be able to choose a different website, the problem is that when the web view goes invisible the flash media players stays stuck on the screen and blocks the buttons, how can I fix this? It would be ok if the media player stays behind the buttons but I cannot find an answer, any help will be highly appreciated, Thank you.

更新与code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:layout_width="match_parent" android:orientation="vertical">
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Web 1" android:id="@+id/buttonWeb1"></Button>
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/buttonWeb2" android:text="Web 2"></Button>
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Web 3" android:id="@+id/buttonWeb3"></Button>
</LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout2" android:layout_width="match_parent" android:orientation="vertical">
    <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/buttonBack" android:text="Back to Buttons"></Button>
    <WebView android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/webView"></WebView>
</LinearLayout>

和主要活动

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.LinearLayout;

public class FlashejemploActivity extends Activity {

WebView wv;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
      setContentView(R.layout.main);
      getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

    final LinearLayout buttons = (LinearLayout) findViewById(R.id.linearLayout1);
    final LinearLayout webV = (LinearLayout) findViewById(R.id.linearLayout2);
    final Button   web1 = (Button) findViewById(R.id.buttonWeb1);
    final Button   web2 = (Button) findViewById(R.id.buttonWeb2);
    final Button   web3 = (Button) findViewById(R.id.buttonWeb3);
    final Button   back = (Button) findViewById(R.id.buttonBack);

      wv = (WebView) findViewById(R.id.webView );
      wv.getSettings().setJavaScriptEnabled(true);
      wv.getSettings().setPluginsEnabled(true);
      wv.setWebViewClient(new WebViewClient());
      wv.setInitialScale(1);
      wv.getSettings().setBuiltInZoomControls(true);
      wv.getSettings().setUseWideViewPort(true);


      final Activity PActivity = this;
      wv.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress)   
        {

        PActivity.setTitle("Cargando....");
        PActivity.setProgress(progress * 100); 

        if(progress == 100)
               PActivity.setTitle(R.string.app_name);
          }
        });

    webV.setVisibility(View.GONE);

     web1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                buttons.setVisibility(View.GONE);
                webV.setVisibility(View.VISIBLE);
                wv.loadUrl("http://los40.com.mx/Player.htm");
            }});
     web2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                buttons.setVisibility(View.GONE);
                webV.setVisibility(View.VISIBLE);
                wv.loadUrl("http://www.beat1009.com.mx/n2/paginas/radio.php");
            }});
     web3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                buttons.setVisibility(View.GONE);
                webV.setVisibility(View.VISIBLE);
                wv.loadUrl("http://besame.com.mx/Player.htm");
            }});
     back.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                buttons.setVisibility(View.VISIBLE);
                webV.setVisibility(View.GONE);

            }});

}

}

推荐答案

我知道它已经有一段时间,但我刚才所得到的WebView清空解决了类似的问题。

I know its been a while but I have just solved a similar problem by getting the webview to empty

wv.loadUrl("about:blank");