mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
Fixed API version issue
This commit is contained in:
@@ -33,3 +33,16 @@ We use reflection to automatically create an adapter when inflating a view.
|
||||
For example, if ```android.widget.Button``` instance is being created, we could simply create an adapter instance using reflection by getting the package name and simple name of the widget.
|
||||
|
||||
See ```XMLLayoutInflater#onCreateAttributeAdapter(View)```.
|
||||
|
||||
### Precautions
|
||||
- Make sure you correctly spell the file names. As you might already know, file names are case sensitive.
|
||||
- Some methods (or even classes) are not available for earlier versions of Android. The classes or methods you're using must be compatible with API 24.
|
||||
|
||||
You could also check if you can use a method. Some methods are already implemented in ViewAttrAdapter so you won't have to rewrite them.
|
||||
For example:
|
||||
```java
|
||||
isApi26() // Android 8 (Oreo)
|
||||
isApi28() // Android 9 (Pie)
|
||||
isApi29() // Android 10 (Q)
|
||||
isApi30() // Android 11 (R)
|
||||
```
|
||||
|
||||
+6
-2
@@ -81,10 +81,14 @@ public class ProgressBarAttrAdapter extends ViewAttrAdapter {
|
||||
}
|
||||
break;
|
||||
case "minHeight" :
|
||||
pb.setMinHeight(parseDimension(value, 0, dm, resFinder));
|
||||
if (isApi29()) {
|
||||
pb.setMinHeight(parseDimension(value, 0, dm, resFinder));
|
||||
}
|
||||
break;
|
||||
case "minWidth" :
|
||||
pb.setMinWidth(parseDimension(value, 0, dm, resFinder));
|
||||
if (isApi29()) {
|
||||
pb.setMinWidth(parseDimension(value, 0, dm, resFinder));
|
||||
}
|
||||
break;
|
||||
case "progress" :
|
||||
pb.setProgress(parseInteger(value, 50));
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# SDK Data
|
||||
These files are taken directly from the Android SDK
|
||||
Reference in New Issue
Block a user