2017-12-22 19 views
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; 
} 
} 

그리고 이것은 결과입니다

Capture

이있는 .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?

미리 감사드립니다.

+1

이미지가로드되지 않는다고 말하는 피카소의 logcat에 오류가 있습니까? –

+1

브라우저에서 URL을 시도해보고 작동하면 picasso –

+0

에서 XML이 작동합니다. –

답변

0

피카소에 날씨를 추가하기 전에 날씨가 유효한지 여부를 확인한 다음 유효한 코드 인 경우 아래 코드를 getView()에서 제거하십시오. fit().centerCrop() 이미지가 크면 설정되지 않기 때문에 fit().centerCrop()을 제거하십시오. xml에 android:src="@drawable/ic_launcher" 속성을 추가 한 경우이 또한 제거하십시오. Manifest에 인터넷 사용 권한을 추가했는지 여부를 확인하십시오.

<uses-permission android:name="android.permission.INTERNET" /> 

이를 사용

if (mPicture != null) { 
    Picasso.with(context).load(userInformation.getUri()).into(mPicture); 
    } 

는 도움이되기를 바랍니다.