0

Ich habe eine Toolbar mit der ID 'toolbar_footer'. Wie man diese Symbolleiste für bestimmte URLs versteckt, zB: 'index.php'. Ein Teil der Hauptaktivität meines Projekts ist unten angegeben. Ich habe es viele Male versucht und kann es nicht richtig mit den gegebenen Antworten arbeiten und den Code mit dem XML Layout Code aktualisieren.Toolbar verstecken bei bestimmten Webview URLs funktioniert nicht

Bitte Hilfe tun .. Ich bin auf dieser problemm für Monate

private class UriWebViewClient extends WebViewClient { 
     @Override 
     public boolean shouldOverrideUrlLoading(WebView view, String url) { 

      String host = Uri.parse(url).getHost(); 

      urlData = url; 


      if (target_url_prefix.equals(host)) { 
       if(url.contains("index.php") || url.contains("login.php") || url.contains("register.php"))   { 
        System.out.println("This is my target url 2"); 
        System.out.println(url); 
        //showToolBar = false; 
        findViewById(R.id.toolbar_footer).setVisibility(View.GONE); 
       } 
       else 
       { 
        findViewById(R.id.toolbar_footer).setVisibility(View.VISIBLE); 
       } 
       if (mWebviewPop != null) { 
        mWebviewPop.setVisibility(View.GONE); 
        mContainer.removeView(mWebviewPop); 
        mWebviewPop = null; 
       } 

       return false; 

      } 

      boolean result = UrlHander.checkUrl(MainActivity.this, url); 
      if (result) { 
       ProgressDialogHelper.dismissProgress(); 
      } else { 
       currentUrl = url; 

       if (!show_content) { 
        if(url.contains("index.php") || url.contains("login.php") || url.contains("register.php"))   { 
         System.out.println("This is my target url 2"); 
         System.out.println(url); 
         //showToolBar = false; 
         findViewById(R.id.toolbar_footer).setVisibility(View.GONE); 
         findViewById(R.id.fab).setVisibility(View.GONE); 
        } 
        else 
        { 
         findViewById(R.id.toolbar_footer).setVisibility(View.VISIBLE); 
         findViewById(R.id.fab).setVisibility(View.VISIBLE); 
        } 

        ProgressDialogHelper.showProgress(MainActivity.this); 
       } 
      } 
      return result; 
     } 


     @Override 
     public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { 
      if (!NetworkHandler.isNetworkAvailable(view.getContext())) { 
       view.loadUrl("file:///android_asset/NoInternet.html"); 

      } 
      hideStatusBar(); 
      ProgressDialogHelper.dismissProgress(); 
     } 

     @Override 
     public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { 
      super.onReceivedError(view, errorCode, description, failingUrl); 
      if (!NetworkHandler.isNetworkAvailable(view.getContext())) { 
       view.loadUrl("file:///android_asset/NoInternet.html"); 
      } 
      hideStatusBar(); 
      ProgressDialogHelper.dismissProgress(); 
     } 

     @Override 
     public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { 
      super.onReceivedHttpError(view, request, errorResponse); 
      if (!NetworkHandler.isNetworkAvailable(view.getContext())) { 
       view.loadUrl("file:///android_asset/NoInternet.html"); 
      } 
      hideStatusBar(); 
      ProgressDialogHelper.dismissProgress(); 
     } 

     @Override 
     public void onPageStarted(WebView view, String url, Bitmap favicon) { 
      if(url.contains("index.php") || url.contains("login.php") || url.contains("register.php"))   { 
       System.out.println("This is my target url 2"); 
       System.out.println(url); 
       //showToolBar = false; 
       findViewById(R.id.toolbar_footer).setVisibility(View.GONE); 
       findViewById(R.id.fab).setVisibility(View.GONE); 
      } 
      else 
      { 
       findViewById(R.id.toolbar_footer).setVisibility(View.VISIBLE); 
       findViewById(R.id.fab).setVisibility(View.VISIBLE); 
      } 

     } 

Meine Layout-Datei ist

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:fab="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:id="@+id/webview_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 

     android:visibility="invisible" 
     tools:context=".universalwebview.MainActivity"> 

     <WebView 
      android:id="@+id/webview" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:scrollbars="none" /> 
    </FrameLayout> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_gravity="right|bottom" 
     android:layout_marginBottom="70dp" 
     android:layout_marginRight="10dp" 
     android:clickable="true" 
     android:src="@drawable/ic_action_share" 
     app:backgroundTint="#00a478" 
     app:borderWidth="0dp" 
     app:elevation="6dp" 
     app:fabSize="normal" 
     app:pressedTranslationZ="12dp" 
     app:rippleColor="#00a470" /> 
    <LinearLayout 
     android:id="@+id/toolbar_footer" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:background="#333" 
     android:orientation="horizontal"> 

     <ImageView 
      android:id="@+id/home" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="?attr/selectableItemBackground" 
      android:clickable="true" 
      android:padding="10dp" 
      android:src="@drawable/ic_action_home" 
      android:tint="@color/tintcolor" /> 

     <ImageView 
      android:id="@+id/search" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="?attr/selectableItemBackground" 
      android:clickable="true" 
      android:padding="10dp" 
      android:src="@drawable/ic_action_search" 
      android:tint="@color/tintcolor" /> 

     <ImageView 
      android:id="@+id/uploadvideo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="?attr/selectableItemBackground" 
      android:clickable="true" 
      android:padding="10dp" 
      android:src="@drawable/ic_action_add" 
      android:tint="#00a478" /> 

     <ImageView 
      android:id="@+id/profile" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="?attr/selectableItemBackground" 
      android:clickable="true" 
      android:padding="10dp" 
      android:src="@drawable/ic_action_profile" 
      android:tint="@color/tintcolor" /> 


     <ImageView 
      android:id="@+id/settings" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="?attr/selectableItemBackground" 
      android:clickable="true" 
      android:padding="10dp" 
      android:src="@drawable/ic_action_settings" 
      android:tint="@color/tintcolor" /> 

    </LinearLayout> 

    <ImageView 
     android:id="@+id/image_splash" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="centerCrop" 
     android:visibility="visible" 
     android:src="@drawable/splash" /> 
</RelativeLayout> 

Antwort

0

für Symbolleiste verstecken Sie diese Zeile setzen müssen. getSupportActionBar().hide();

Also zunächst geprüft, ob die URL und dann setzen Sie diese Zeile, wenn Block if(url.contains(“your text”){ getSupportActionBar().hide(); }

Verwandte Themen