What I have tried is this way:
val arrlay: Array<@LayoutRes Int> =[R.layout.tab_basales,R.layout.tab_pcs,R.layout.tab_portadores]
but it gives me the following error
Unsupported [Collection literals outside of annotations]
This annotation is not applicable to target 'type usage'
Your syntax is correct but it just
@LayoutRes
doesn't support that target.In Java it would be like this:
But keep in mind that the vast majority of annotations do not support this usage.
@LayoutRes
it is used in parameters of a function to indicate that the value it receives must be the id of a layout and it only serves to show a warning if this is not true. On a property it doesn't make much sense because you already know what its value is going to be and anyway the linter doesn't work if the value comes out of a variable. You can safely remove it, and also remember to use array primitives whenever possible.IntArray
is the equivalent ofint[]
(primitive) in Java, whileArray<Int>
is the equivalent ofInteger[]
(boxed)