Beginning Android Layouts - Part 9: RelativeLayout | Ray Wenderlich

Learn about how to use the RelativeLayout ViewGroup to position sibling views with specific relationships to one another.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4701-beginning-android-layouts/lessons/9

I encountered a problem with this lesson when I tried to add the app:srcCompat line to the file list_item_team_member.xml. The “app” tag showed in red, and my build failed. Browsing online led me to add xmlns:app=“http://schemas.android.com/apk/res-auto” to the header, which solved the problem. I am using Android Studio 3.1.3 on MacOS El Capitan.

Otherwise, everything is going very well. :slight_smile:

Thanks Rob! Yep, adding the app namespace will be necessary when using custom attributes like app:srcCompat, and similarly sometimes you’ll need the tools namespace, for example to add a tools:text attribute to a TextView so that you can see a preview in Android Studio.

Usually, when you add something like an app:srcCompat attribute, you can then hit Option+Return on macOS (or Alt+Enter on PC) to automatically add the app namespace to the header. Android Studio is sometimes finicky about doing this, but if you move the cursor to the error and once you see app underlined, telling you that Android Studio is ready to add the namespace, it will usually work.

Thank you for the fast response, and the tip. I’ll look out for that prompting in the future.

Next problem.
After following the instructions to install the Picasso library, the tutorial sends me to TeamMemberAdapter and asked that I add a line that starts with:
Picasso.with

However, after entering Picasso, it doesn’t seem to offer a .with extension, and if I enter it manually the “with” shows up in red, and subsequently refuses to build. The associated error message is “Unresolved reference”, giving options to rename the reference, or to introduce a local variable.

Not sure where to go from here…


Can’t reply with a thank you as I’ve reached my posting limit for the thread, but I again appreciate the help. Hopefully there won’t be too many more time-bombs awaiting me!

@macsimus Can you please help with this when you get a chance? Thank you - much appreciated! :]

Since the recording of this course, there was a change in the Picasso library to rename with() to get(). So if you’re using the most recent version of Picasso, just replace with() with get() and you should be good to go. Thanks!

Hi Macsimus,

I have encounter a red letters on with in TeamMemberAdapter.kt after I follow the instructions on adding Picasso 2.71828 dependency. " Picasso.with(itemView.teamMemberAvatar.context).load(member.avatarUrl)
.into(itemView.teamMemberAvatar)" the “with” is highlighted red and asking for reference or introduce a variable?

Is this something wrong with Picasso dependency? or I need declare something else?

Thanks
John newbie on android

Hi John,

Since the recording of this course, there was a change in the Picasso library to replace with(context) with get() . So if you’re using the most recent version of Picasso, just replace with(...) with get() and you should be good to go. Thanks!

Thanks for answer quickly, although, I have encounter another "Too many arguments for public open fun get(): Picasso! defined in com.squareup.picasso.Picasso " error. Since the new Picasso update in dependency, it was only choice that I can pick from the list and I did not see version 2.5.2 any more.

Here the error in the code below
fun bind(member;Member) {
this.member = member
Picasso.get(itemView.teamMemberAvatar.context).load(member.avatarUrl).into(itemView.teamMemberAvatar)
itemView.teamMemberLogin.text = member.login
itemView.teamMemberType.text = member.type
}

Thanks John. You don’t need any parameters in the get() call. :]