URL HERE如何在android應用程序中使用webview作爲瀏覽器?
當我在我的應用程序的WebView加載上面的網址將其更改爲http://m.allrecipes.com但是,當我在瀏覽器的URL加載相同的URL http://allrecipes.com。
有沒有辦法在我的應用程序的WebView加載正常的URL(http://allrecipes.com)不加載頁面移動(http://m.allrecipes.com)
有人知道請幫我
go.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (Searchtext.getText().toString().equalsIgnoreCase("")) {
alertDialog = new AlertDialog.Builder(OnlineRecipe.this)
.create();
alertDialog.setTitle("Message");
alertDialog.setMessage("Please Enter Some Word");
alertDialog.setButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
// Write your code here to execute after
// dialog closed
alertDialog.dismiss();
}
});
// Showing Alert Message
alertDialog.show();
} else {
String url = "http://allrecipes.com/search/default.aspx?qt=k&wt="
+ Searchtext.getText().toString()
+ "&rt=r&origin=Recipe Search Results";
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl(url);
}
}
});
謝謝你的回覆,但我不是這個意思。當我想在webview中加載上面的url時,它會變成手機兼容的網址爲「m.allrecipes.com」我不想要這個,我也不想要任何新的活動 – Nas 2013-04-06 07:00:01
您必須爲每個頁面開始一個新的活動。 webView.loadUrl(getIntent()。getExtras()。getString(「url」)); - 在這裏你可以把靜態的網頁。也許:m.allrecipes.com – 2013-04-06 07:09:09
@ d.danailov,這是不正確的。您可以輕鬆將Web視圖放入片段或活動中,並在每次需要新頁面時調用loadurl。 – cYrixmorten 2013-09-29 18:55:26