Java 如何在android中使用recylerview在cardview中设置默认照片
我有一个使用recyclerview列表的cardview,其中显示了用户的数据。来自服务器的数据。。但我想设置一个默认的用户照片,如果用户不上传自己的照片,那么虚拟照片应该显示在imageview中。。请指导我怎么做 试试看Java 如何在android中使用recylerview在cardview中设置默认照片,java,android,android-studio-3.0,Java,Android,Android Studio 3.0,我有一个使用recyclerview列表的cardview,其中显示了用户的数据。来自服务器的数据。。但我想设置一个默认的用户照片,如果用户不上传自己的照片,那么虚拟照片应该显示在imageview中。。请指导我怎么做 试试看 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
... >
<!-- A CardView that contains a ImageView-->
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp">
<ImageView
android:id="@+id/image_view_user_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/default_photo" //your default photo
/>
</android.support.v7.widget.CardView>
</LinearLayout>
当您收到服务器照片时,只需将它们放入image\u view\u user\u photo
,如果用户没有照片,默认照片将不会更改