有时候我们会动态创建view,并且需要给其赋予一个id,我们可能会这样写:
llBody=newLinearLayout(getContext());
llBody.setId(1234);
这样写运行并不会报错,但是编译器会提示:
Expected resource of type id less... (Ctrl+F1)
This inspection looks at Android API calls that have been annotated with various support annotations (such as RequiresPermission or UiThread) and flags any calls that are not using the API correctly as specified by the annotations. Examples of errors flagged by this inspection:
Passing the wrong type of resource integer (such as R.string) to an API that expects a different type (such as R.dimen).
Forgetting to invoke the overridden method (via super) in methods that require it
Calling a method that requires a permission without having declared that permission in the manifest
Passing a resource color reference to a method which expects an RGB integer value.
...and many more.
并且打签名包会提示error,但是不会影响打包的成功。
作为一个程序员坚决不能容忍小红线,可以这么修改:
1、API 17+
setId(View.generateViewId())
2、API小于17时:
llBody.setId(newInteger(2));
以上,小红线没了!打签名包不会提示error。