0
일부 사용자를 나열하는 데 사용자 지정 어댑터를 사용하고 있는데 Firebase
을 던져 넣으 려는데 Picasso
을 사용하고 있지만 목록의 그림을 URL에 표시 할 수는 없습니다 .ListView 어댑터 with Picasso
이 어댑터입니다 :
public class customAdapter extends ArrayAdapter<UserInformation> {
private Context context;
private LayoutInflater inflater;
public customAdapter(Context context, int layoutResource, List<UserInformation> userInformationsList) {
super(context, layoutResource, userInformationsList);
this.context=context;
inflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
view = layoutInflater.inflate(R.layout.userslist, null);
}
UserInformation userInformation = getItem(position);
if (userInformation != null) {
TextView Name = (TextView) view.findViewById(R.id.textNameList);
//name.setText(name[position]);
ImageView mPicture = (ImageView) view.findViewById(R.id.imageViewPicture);
String uri ;
//email.setText(Email[position]);
TextView gender = (TextView) view.findViewById(R.id.textGenderList);
//gender.setText(Gender[position]);
TextView birthday = (TextView) view.findViewById(R.id.textBirthdayList);
//birthday.setText(Birthday[position]);
if (Name != null) {
Name.setText(userInformation.getName());
}
if (mPicture != null) {
uri=(userInformation.getUri());
Picasso.with(context).load(uri).fit().centerCrop().into(mPicture);
}
if (gender != null) {
gender.setText(userInformation.getGender());
}
if (birthday != null) {
birthday.setText(userInformation.getBirthday());
}
}
return view;
}
}
그리고 이것은 결과입니다
이있는 .XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/colorEditText">
<ImageView
android:layout_marginTop="30dp"
android:layout_marginLeft="30dp"
android:id="@+id/imageViewPicture"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:id="@+id/textNameList"
android:textSize="25dp"
android:textAlignment="textStart"
android:text="Name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/textEmailList"
android:textSize="15dp"
android:textAlignment="textStart"
android:text="Age"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/textBirthdayList"
android:textSize="15dp"
android:textAlignment="textStart"
android:text="Birthday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/textGenderList"
android:textSize="15dp"
android:textAlignment="textStart"
android:text="gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:layout_margin="10dp"/>
</LinearLayout>
모든 sugestion?
미리 감사드립니다.
이미지가로드되지 않는다고 말하는 피카소의 logcat에 오류가 있습니까? –
브라우저에서 URL을 시도해보고 작동하면 picasso –
에서 XML이 작동합니다. –