Android Application Development Cookbook: 93 Recipes for Building Winning Apps


WebView webView = (WebView) findViewById(R.id.WebView01)



Download 32,34 Mb.
Pdf ko'rish
bet55/56
Sana26.02.2022
Hajmi32,34 Mb.
#470540
1   ...   48   49   50   51   52   53   54   55   56
Bog'liq
Android Application Development Cookbook

WebView webView = (WebView) findViewById(R.id.WebView01);
webView.setWebViewClient(new Callback());
WebSettings webSettings = webView.getSettings();
webSettings.setBuiltInZoomControls(true);
webView.loadUrl("http://www.android.com/images/whatsnew/jb-new-logo.png");
}
private class Callback extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, 
String url) {
return (false);
}
}
}
To display the built-in zoom controls, you need to first get the 
WebSettings
property from the 
WebView
and then call its 
setBuiltInZoomControls()
method. 
www.it-ebooks.info


 
Recipe 2.7 displaying Web pages

59
note
Although most Android devices support multi-touch screens, the built-in 
zoom controls are useful for zooming your web content when testing your appli-
cation on the Android emulator. 
Sometimes when you load a page that redirects you (such as loading 
www.wrox.com
 redirects you to 
www.wrox.com/wileyCDA
), the 
WebView
will cause your application to launch the device’s browser 
application to load the desired page. For example, if you ask the 
WebView
to load 
www.wrox.com
, Wrox 
.com will automatically redirect you to 
www.wrox.com/WileyCDA
/. In this case, your application will 
automatically launch the device’s browser application to load your page. To prevent this from happen-
ing, you need to implement the 
WebViewClient
class and override the 
shouldOverrideUrlLoading()
method, as shown in the preceding example.
Finally, to use the 
WebView
in your application, you need to remember to add the 
INTERNET
permis-
sion to your 
AndroidManifest.xml
file:

Download 32,34 Mb.

Do'stlaringiz bilan baham:
1   ...   48   49   50   51   52   53   54   55   56




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish