The Android SDK provides a custom scheme to load assets from the application's .apk file in WebView. The prefix "file:///android_asset/" will cause WebView to load content from the current application's assets folder. For example, a myimage.gif file in the /assets folder can be used in the html image tag as:
<img src="file:///android_asset/myimage.gif">WebView.HitTestResult | |
WebView.PictureListener | Interface to listen for new pictures as they change. |
Value | ||||
---|---|---|---|---|
String | SCHEME_GEO | URI scheme for map address | "geo:0,0?q=" | |
String | SCHEME_MAILTO | URI scheme for email address | "mailto:" | |
String | SCHEME_TEL | URI scheme for telephone number | "tel:" |
WebView(Context context) | ||||||
Construct a new WebView with a Context object. | ||||||
WebView(Context context, AttributeSet attrs) | ||||||
Construct a new WebView with layout parameters. | ||||||
WebView(Context context, AttributeSet attrs, int defStyle) | ||||||
Construct a new WebView with layout parameters and a default style. |
void | addJavascriptInterface(Object obj, String interfaceName) | |||||
Use this function to bind a Java object to Javascript so that the methods can be accessed from Javascript. | ||||||
boolean | canGoBack() | |||||
Return true if this WebView has a back history item. | ||||||
boolean | canGoBackOrForward(int steps) | |||||
Return true if the page can go back or forward the given number of steps. | ||||||
boolean | canGoForward() | |||||
Return true if this WebView has a forward history item. | ||||||
Picture | capturePicture() | |||||
Return a new picture that captures the current display of the webview. | ||||||
void | clearCache() | |||||
Clear the resource cache. | ||||||
void | clearFormData() | |||||
Make sure that clearing the form data removes the adapter from the currently focused textfield if there is one. | ||||||
void | clearHistory() | |||||
Tell the WebView to clear its internal back/forward list. | ||||||
void | clearMatches() | |||||
Clear the highlighting surrounding text matches created by findAll. | ||||||
void | clearSslPreferences() | |||||
Clear the SSL preferences table stored in response to proceeding with SSL certificate errors. | ||||||
void | clearView() | |||||
Clear the view so that onDraw() will draw nothing but white background, and onMeasure() will return 0 if MeasureSpec is not MeasureSpec.EXACTLY | ||||||
void | computeScroll() | |||||
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. | ||||||
WebBackForwardList | copyBackForwardList() | |||||
Return the WebBackForwardList for this WebView. | ||||||
void | debugDump() | |||||
void | destroy() | |||||
Destroy the internal state of the WebView. | ||||||
static | void | disablePlatformNotifications() | ||||
If platform notifications are enabled, this should be called from onPause() or onStop(). | ||||||
boolean | dispatchKeyEvent(KeyEvent event) | |||||
Dispatch a key event to the next view on the focus path. | ||||||
void | documentHasImages(Message response) | |||||
Query the document to see if it contains any image references. | ||||||
static | void | enablePlatformNotifications() | ||||
Enables platform notifications of data state and proxy changes. | ||||||
static | String | findAddress(String addr) | ||||
Return the first substring consisting of the address of a physical location. | ||||||
void | findAll(String find, Message response) | |||||
Find all instances of find on the page and highlight them. | ||||||
void | findFirst(String find, Message response) | |||||
Find and highlight the first occurance of find, beginning with the start of the page. | ||||||
void | findNext(String find, Message response) | |||||
Find and highlight the next occurance of the String find, beginning with the current selection. | ||||||
void | findPrevious(String find, Message response) | |||||
Find and highlight the previous occurance of the String find, beginning with the current selection. | ||||||
void | flingScroll(int vx, int vy) | |||||
SslCertificate | getCertificate() | |||||
int | getContentHeight() | |||||
Bitmap | getFavicon() | |||||
Get the favicon for the current page. | ||||||
WebView.HitTestResult | getHitTestResult() | |||||
Return a HitTestResult based on the current focus node. | ||||||
String[] | getHttpAuthUsernamePassword(String host, String realm) | |||||
Retrieve the HTTP authentication username and password for a given host & realm pair | ||||||
synchronized | static | PluginList | getPluginList() | |||
Return the list of currently loaded plugins. | ||||||
int | getProgress() | |||||
Get the progress for the current page. | ||||||
float | getScale() | |||||
Return the current scale of the WebView | ||||||
WebSettings | getSettings() | |||||
Return the WebSettings object used to control the settings for this WebView. | ||||||
String | getTitle() | |||||
Get the title for the current page. | ||||||
String | getUrl() | |||||
Get the url for the current page. | ||||||
View | getZoomControls() | |||||
Returns a view containing zoom controls i.e. | ||||||
void | goBack() | |||||
Go back in the history of this WebView. | ||||||
void | goBackOrForward(int steps) | |||||
Go to the history item that is the number of steps away from the current item. | ||||||
void | goForward() | |||||
Go forward in the history of this WebView. | ||||||
void | invokeZoomPicker() | |||||
Invoke the graphical zoom picker widget for this WebView. | ||||||
void | loadData(String data, String mimeType, String encoding) | |||||
Load the given data into the WebView. | ||||||
void | loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String failUrl) | |||||
Load the given data into the WebView, use the provided URL as the base URL for the content. | ||||||
void | loadUrl(String url) | |||||
Load the given url. | ||||||
void | onAnimationStart() | |||||
Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view. | ||||||
void | onChildViewAdded(View parent, View child) | |||||
Called when a new child is added to a parent view. | ||||||
void | onChildViewRemoved(View p, View child) | |||||
Called when a child is removed from a parent view. | ||||||
void | onGlobalFocusChanged(View oldFocus, View newFocus) | |||||
Callback method to be invoked when the focus changes in the view tree. | ||||||
boolean | onKeyDown(int keyCode, KeyEvent event) | |||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released, if the view is enabled and clickable. | ||||||
boolean | onKeyUp(int keyCode, KeyEvent event) | |||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released. | ||||||
boolean | onTouchEvent(MotionEvent ev) | |||||
Implement this method to handle touch screen motion events. | ||||||
boolean | onTrackballEvent(MotionEvent ev) | |||||
Implement this method to handle trackball motion events. | ||||||
void | onWindowFocusChanged(boolean hasWindowFocus) | |||||
Called when the window containing this view gains or loses focus. | ||||||
boolean | pageDown(boolean bottom) | |||||
Scroll the contents of the view down by half the page size | ||||||
boolean | pageUp(boolean top) | |||||
Scroll the contents of the view up by half the view size | ||||||
void | pauseTimers() | |||||
Pause all layout, parsing, and javascript timers. | ||||||
boolean | performLongClick() | |||||
Call this view's OnLongClickListener, if it is defined. | ||||||
void | refreshPlugins(boolean reloadOpenPages) | |||||
Signal the WebCore thread to refresh its list of plugins. | ||||||
void | reload() | |||||
Reload the current url. | ||||||
boolean | requestChildRectangleOnScreen(View child, Rect rect, boolean immediate) | |||||
Called when a child of this group wants a particular rectangle to be positioned onto the screen. | ||||||
boolean | requestFocus(int direction, Rect previouslyFocusedRect) | |||||
Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from. Looks for a view to give focus to respecting the setting specified by getDescendantFocusability(). | ||||||
void | requestFocusNodeHref(Message hrefMsg) | |||||
Request the href of an anchor element due to getFocusNodePath returning "href." If hrefMsg is null, this method returns immediately and does not dispatch hrefMsg to its target. | ||||||
void | requestImageRef(Message msg) | |||||
Request the url of the image last touched by the user. | ||||||
WebBackForwardList | restoreState(Bundle inState) | |||||
Restore the state of this WebView from the given map used in Activity.onThaw. | ||||||
void | resumeTimers() | |||||
Resume all layout, parsing, and javascript timers. | ||||||
void | savePassword(String host, String username, String password) | |||||
Save the username and password for a particular host in the WebView's internal database. | ||||||
WebBackForwardList | saveState(Bundle outState) | |||||
Save the state of this WebView used in Activity.onSaveInstanceState. | ||||||
void | setBackgroundColor(int color) | |||||
Set the background color. | ||||||
void | setCertificate(SslCertificate certificate) | |||||
Sets the SSL certificate for the main top-level page. | ||||||
void | setDownloadListener(DownloadListener listener) | |||||
Register the interface to be used when content can not be handled by the rendering engine, and should be downloaded instead. | ||||||
void | setHttpAuthUsernamePassword(String host, String realm, String username, String password) | |||||
Set the HTTP authentication credentials for a given host and realm. | ||||||
void | setInitialScale(int scaleInPercent) | |||||
Set the initial scale for the WebView. | ||||||
void | setLayoutParams(ViewGroup.LayoutParams params) | |||||
Set the layout parameters associated with this view. | ||||||
void | setMapTrackballToArrowKeys(boolean setMap) | |||||
void | setPictureListener(WebView.PictureListener listener) | |||||
Set the Picture listener. | ||||||
void | setWebChromeClient(WebChromeClient client) | |||||
Set the chrome handler. | ||||||
void | setWebViewClient(WebViewClient client) | |||||
Set the WebViewClient that will receive various notifications and requests. | ||||||
void | stopLoading() | |||||
Stop the current load. | ||||||
boolean | zoomIn() | |||||
Perform zoom in in the webview | ||||||
boolean | zoomOut() | |||||
Perform zoom out in the webview |
int | computeHorizontalScrollRange() | |||||
Compute the horizontal range that the horizontal scrollbar represents. |
||||||
int | computeVerticalScrollRange() | |||||
Compute the vertical range that the vertical scrollbar represents. |
||||||
void | finalize() | |||||
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. | ||||||
void | onAnimationEnd() | |||||
Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view. | ||||||
void | onAttachedToWindow() | |||||
This is called when the view is attached to a window. | ||||||
void | onDetachedFromWindow() | |||||
This is called when the view is detached from a window. | ||||||
void | onDraw(Canvas canvas) | |||||
Implement this to do your drawing. | ||||||
void | onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) | |||||
Called by the view system when the focus state of this view changes. | ||||||
void | onMeasure(int widthMeasureSpec, int heightMeasureSpec) | |||||
Measure the view and its content to determine the measured width and the measured height. |
||||||
void | onScrollChanged(int l, int t, int oldl, int oldt) | |||||
This is called in response to an internal scroll in this view (i.e., the view scrolled its own contents). | ||||||
void | onSizeChanged(int w, int h, int ow, int oh) | |||||
This is called during layout when the size of this view has changed. |
context | A Context object used to access application assets. |
---|
context | A Context object used to access application assets. |
---|---|
attrs | An AttributeSet passed to our parent. |
context | A Context object used to access application assets. |
---|---|
attrs | An AttributeSet passed to our parent. |
defStyle | The default style resource ID. |
obj | The class instance to bind to Javascript |
---|---|
interfaceName | The name to used to expose the class in Javascript |
steps | The negative or positive number of steps to move the history. |
---|
Note: this really needs to be a static method as it clears cache for all WebView. But we need mWebViewCore to send message to WebCore thread, so we can't make this static.
event | The key event to be dispatched. |
---|
response | The message that will be dispatched with the result. |
---|
addr | The string to search for addresses. |
---|
find | String to find. |
---|---|
response | A Message object that will be dispatched with the result as the arg1 member. The result will be the number of matches to the String find. |
find | String to find. |
---|---|
response | A Message object that will be dispatched with the result as the arg1 member. A result of 1 means the search succeeded. |
find | String to find. |
---|---|
response | A Message object that will be dispatched with the result as the arg1 member. A result of 1 means the search succeeded. |
find | String to find. |
---|---|
response | A Message object that will be dispatched with the result as the arg1 member. A result of 1 means the search succeeded. |
host | The host for which the credentials apply. |
---|---|
realm | The realm for which the credentials apply. |
steps | The number of steps to take back or forward in the back forward list. |
---|
data | A String of data in the given encoding. |
---|---|
mimeType | The MIMEType of the data. i.e. text/html, image/jpeg |
encoding | The encoding of the data. i.e. utf-8, base64 |
baseUrl | Url to resolve relative paths with, if null defaults to "about:blank" |
---|---|
data | A String of data in the given encoding. |
mimeType | The MIMEType of the data. i.e. text/html. If null, defaults to "text/html" |
encoding | The encoding of the data. i.e. utf-8, us-ascii |
failUrl | URL to use if the content fails to load or null. |
url | The url of the resource to load. |
---|
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
ev | The motion event. |
---|
ev | The motion event. |
---|
hasWindowFocus | True if the window containing this view now has focus, false otherwise. |
---|
bottom | true to jump to bottom of page |
---|
top | true to jump to the top of the page |
---|
reloadOpenPages | Set to true to reload all open pages. |
---|
ViewGroups overriding this should uphold the contract:
child | The direct child making the request. |
---|---|
rect | The rectangle in the child's coordinates the child wishes to be on the screen. |
immediate | True to forbid animated or delayed scrolling, false otherwise |
direction | One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT |
---|---|
previouslyFocusedRect | The rectangle (in this View's coordinate system) to give a finer grained hint about where focus is coming from. May be null if there is no hint. |
hrefMsg | This message will be dispatched with the result of the request as the data member with "url" as key. The result can be null. |
---|
msg | This message will be dispatched with the result of the request as the data member with "url" as key. The result can be null. |
---|
inState | The incoming Bundle of state. |
---|
host | The host that required the credentials. |
---|---|
username | The username for the given host. |
password | The password for the given host. |
outState | The Bundle to store the WebView state. |
---|
color | the ARGB color described by Color.java |
---|
listener | An implementation of DownloadListener. |
---|
host | The host for the credentials. |
---|---|
realm | The realm for the credentials. |
username | The username for the password. If it is null, it means password can't be saved. |
password | The password |
scaleInPercent | The initial scale in percent. |
---|
params | the layout parameters for this view |
---|
listener | An implementation of WebView.PictureListener. |
---|
client | An implementation of WebChromeClient. |
---|
client | An implementation of WebViewClient. |
---|
Compute the horizontal range that the horizontal scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollExtent() and computeHorizontalScrollOffset().
The default range is the drawing width of this view.
Compute the vertical range that the vertical scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollExtent() and computeVerticalScrollOffset().
The default range is the drawing height of this view.
Note: The virtual machine assumes that the implementation in class Object is empty.
Throwable |
---|
canvas | the canvas on which the background will be drawn |
---|
focused | True if the View has focus; false otherwise. |
---|---|
direction | The direction focus has moved when requestFocus() is called to give this view focus. Values are View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT or View.FOCUS_RIGHT. It may not always apply, in which case use the default. |
previouslyFocusedRect | The rectangle, in this view's coordinate
system, of the previously focused view. If applicable, this will be
passed in as finer grained information about where the focus is coming
from (in addition to direction). Will be null otherwise.
|
Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.
CONTRACT: When overriding this method, you
must call setMeasuredDimension(int, int) to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException
, thrown by
measure(int, int). Calling the superclass'
onMeasure(int, int) is a valid use.
The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.
If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).
widthMeasureSpec | horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. |
---|---|
heightMeasureSpec | vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec. |
l | Current horizontal scroll origin. |
---|---|
t | Current vertical scroll origin. |
oldl | Previous horizontal scroll origin. |
oldt | Previous vertical scroll origin. |
w | Current width of this view. |
---|---|
h | Current height of this view. |
ow | Old width of this view. |
oh | Old height of this view. |
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:56 |