This week's giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP and have Lucian Maly on-line!
See this thread for details.
Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Cannot link layout with adapter

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I cannot link the card view layout with an adapter even tho I followed the general format of context, layout, and array.
The error is on line 27 a red line under r.layout.item_list_view and it says the required is activity and that I gave it an int.
I have no idea why it thinks I gave it an int..

The layout file
 
Malavika Shanker
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My RecipeAdapter
 
Master Rancher
Posts: 4256
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

why it thinks I gave it an int.



R is a class created by the IDE as a place to hold the constants it creates.  Here is the path to R.java for one of my projects:
D:\AndroidDevelopment\workspace\DialogFragmentTest\gen\com\example\dialogfragmenttest\R.java
If you look in R.java there will be an inner class nameed layout and inside of that item_list_view will be defined as an int.

A reference for the R.java file: https://www.javatpoint.com/R-java-file-in-android

The RecipeAdapter class's constructor takes a reference to an Activity as its second argument.  Would the class holding the above statement be the desired Activity?  Then this would refer to that Activity.
 
Saloon Keeper
Posts: 23441
159
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, I believe that R is created by the Android build process, so even if you aren't using an IDE it should be constructed.

Also, interestingly, the latest Android Studio doesn't seem to want me to explicitly reference R anymore.
 
Those are the largest trousers in the world! Especially when next to this ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic