问题描述
我的代码中有这一行:
linearLayout.setBackground(drawable);
setBackground()
显示以下错误:
这是什么意思?
我可以提高我的API等级吗?
Can I raise my API level?
更高/更低的API级别是什么意思?
What does a higher/lower API level mean?
如果API级别更高,是否限制了我的应用可以使用的设备数量?
Does it limit the amount of devices my app can be used on if the API level is higher?
推荐答案
这意味着在API级别16中添加了 setBackground(Drawable)
方法,而较早的设备没有此方法.但是,您应用的 minSdkVersion
为14.因此,除非您采取措施避免在API Level 14和15设备上使用此行,否则您的应用将在这些设备上崩溃.
It means that the setBackground(Drawable)
method was added in API Level 16, and older devices do not have it. However, your app's minSdkVersion
is 14. So, unless you take steps to avoid this line on API Level 14 and 15 devices, your app will crash on those devices.
您可以将 minSdkVersion
设置为16.
是的.如果您说您的 minSdkVersion
是16,则运行版本早于该版本的Android的设备将无法运行您的应用.
Yes. If you say that your minSdkVersion
is 16, then devices running a version of Android older than that cannot run your app.
在撰写本文时,访问Play商店的Android设备中约有90%是在API级别16或更高版本上(即运行Android 4.1或更高版本).
At the time of this writing, about 90% of Android devices accessing the Play Store are on API Level 16 or higher (i.e., are running Android 4.1 or higher).
这篇关于调用需要API级别16(当前最小值为14)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!