Я следую этому руководству https://www.youtube.com/watch?v=ktCpRGGfsls, но изображение не загружается. Я не уверен, почему.
Мой java файл:
mRestaurantTitle = (TextView) findViewById(R.id.titleLabel);
mRateCat = (TextView) findViewById(R.id.rateCatLabel);
mMainImage = (ImageView) findViewById(R.id.mainImage);
Picasso
.get()
.load("http://i.imgur.com/DvpvklR.png")
.into(mMainImage);
и xml файл:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/titleLabel"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pizza Shop"
android:layout_alignParentTop="true"
/>
<TextView
android:id="@+id/rateCatLabel"
android:text = "4.2 Italian"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
></TextView>
<ImageView
android:id="@+id/mainImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/rateCatLabel"
android:layout_below="@id/titleLabel"
>
</ImageView>
</RelativeLayout>
Я добавил <uses-permission android:name="android.permission.INTERNET"/>
в манифест и внедрение com.squareup.picasso:picasso:2.71828
в build.gradle (Модуль: приложение).