java - "android.R.id.content" generates an error with no change to the source code -


this code exercise source code course took. worked fine until afternoon. no change made , re imported , similar project , experienced same new error.

public class tourlistadapter extends arrayadapter<tour> {     context context;     list<tour> tours;       public tourlistadapter(context context, list<tour> tours) {         super(context, android.r.id.content, tours);         this.context = context;         this.tours = tours;     } 

i'm using android studio 1.3

android.r.id.content used work , generates error:

expected resource of type layout.

i've searched stackoverflow , there appears new feature annotates possible mis-matches. somehow android id integer used ok , not longer. did not download new today android studio.

i have re-built, cleaned , sycn'd. have exited , rebooted computer no resolution.

it's not error, it's warning.

as you've noted in question, resource method parameters can annotated indicate type of resource should passed it. android studio checks these parameters based upon name , flags if doesn't match correct type.

however, you've stumbled upon corner-case android studio not deal with. noted this question, android.r.id.content special resource id used obtain root view without knowing actual id of view. sadly, android sdk developers put id resource , not layout resource (it should have been designated android.r.layout.content, it's late change now!).

so, sum up, android studio expecting use r.layout.value here, using special r.id.value. correct , app should still build correctly (mine when tested it) - hence warning, not error.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -