TAILIEUCHUNG - Lập trình Androi part 20

Các bộ công cụ GUI cho phép bạn sử dụng HTML để trình bày thông tin, từ giới hạn renderers HTML (ví dụ, Java / Swing và wxWidgets) để nhúng Internet Explorer vào các ứng dụng NET Android cũng tương tự, trong đó bạn có thể nhúng được xây dựng trong trình duyệt web như là một widget trong hoạt động của riêng bạn, để hiển thị hoặc duyệt web HTML đầy đủ. Các trình duyệt Android được dựa trên WebKit, động cơ tương tự như trình duyệt Safari của Apple, quyền hạn của web | Chapter Embedding the WebKit Browser Other GUI toolkits let you use HTML for presenting information from limited HTML renderers . Java Swing and wxWidgets to embedding Internet Explorer into .NET applications. Android is much the same in that you can embed the built-in web browser as a widget in your own activities for displaying HTML or full-fledged browsing. The Android browser is based on WebKit the same engine that powers Apple s Safari web browser. The Android browser is sufficiently complex that it gets its own Java package . Using the WebView widget itself can be simple or powerful based on your requirements as you ll learn in this chapter. A Browser Writ Small For simple stuff WebView is not significantly different than any other widget in Android. You pop it into a layout tell it which URL to navigate to via Java code and you re finished. For example WebKit Browserl here is a simple layout with a WebView xml version encoding utf-8 LinearLayout xmlns android http apk res android android orientation vertical android layout_width fill_parent android layout_height fill_parent WebView android id @ id webkit android layout_width fill_parent android layout_height fill_parent LinearLayout As with any other widget you need to tell it how it should fill up the space in the layout. In this case it fills all remaining space. 141 142 CHAPTER 13 Embedding the WebKit Browser The Java code is equally simple package import import import public class BrowserDemol extends Activity WebView browser Override public void onCreate Bundle icicle super. onCreate icicle setContentView browser WebView findViewById browser. loadUrl http The only unusual bit with this edition of onCreate is that we invoke loadUrl on the WebView widget to tell it to load a web page in this case the home page of some random firm

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.