0
我想永久隱藏瀏覽器的URL欄,即使人從一個頁面重定向到另一個頁面,它也不應該出現。 這裏是我的.java代碼:如何從Android瀏覽器中隱藏URL欄
package com.example.com.android.royalcastleapp;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.support.v4.app.NavUtils;
public class Bookinghome extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bookinghome);
//Get a reference of WebView holder
WebView webview = (WebView) this.findViewById(R.id.webview);
//Get the settings
WebSettings websettings = webview.getSettings();
//Enable Javascript
websettings.setJavaScriptEnabled(true);
//Make the zoom controls visible
websettings.setBuiltInZoomControls(true);
//Load the default url.
webview.loadUrl("http//okRoom.aspx");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_bookinghome, menu);
return true;
}
}
這裏是我的佈局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<WebView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".Bookinghome"
android:id= "@+id/webview"/>
</RelativeLayout>
如果任何人都可以提出任何改變,我可以做,這將是偉大的!
我沒有問主席先生,我想要的是隱藏在瀏覽器的地址欄中,u能PLZ告訴 – user1643227
@ user1643227:'的WebView '沒有地址欄,所以沒有什麼可以隱藏的。您不能攻擊第三方應用程序,例如試圖「隱藏瀏覽器的地址欄」。相反,您需要按照此答案中的說明將用戶保留在「WebView」中,而不是在鏈接和重定向上打開瀏覽器。 – CommonsWare
@ user1643227:答案是正確的 - 如果您不使用'shouldOverrideUrlLoading(...)',那麼Android將使用股票(內置)瀏覽器應用程序,並且您無法隱藏地址欄。 – Squonk