Take the 2-minute tour ×  I am trying to create a WebView
dynamically using the following code:  mWebView = new
WebView(this);  mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE,
null);   But, when I run the program, my app force quits stating
an error that there is no such method as 'setLayerType'.
However, when I create the Webview via the xml, there seems to
be no problem:  <WebView android:id="@+id/webview"
android:layerType="software" />  I use the 'layertype' attribute
here and the app runs fine. Can somebody please explain the
discrepancy? Is there no way to set the layer type of a WebView
dynamically?  share|improve this question  4 Answers 4  up vote
3 down vote accepted  NOTE: The question "what api level do you
build for?" is VERY different from the question "what is the
minimum api level that you target?".  Given the behaviour you
have described, it suggests you are building with api level >=11
and testing on a device that is api level <11.  Because
.setLayerType is only available from api level