0

Firebaseからプロフィール画像を取得しようとしていますが、断片を使用しています。Firebaseのフラグメントを使用してプロファイル写真を取得するにはどうすればよいですか?

私は断片に新しいです。ここに私のFirebaseデータベース構造は次のとおりです。

database

ストレージ:ここ

Storage

は私の断片である:

public class Profile extends Fragment { 

    private CircleImageView mprofilePic; 
    private TextView mUsername, mDescription, mEditProfile; 
    private ImageButton mSettings; 

    public Profile() { 
     // Required empty public constructor 
    } 

    public static Profile newInstance(int instance) { 
     Bundle args = new Bundle(); 
     args.putInt("argsInstance", instance); 
     Profile profile = new Profile(); 
     profile.setArguments(args); 
     return profile; 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 
     // Inflate the layout for this fragment 
     View profile = inflater.inflate(R.layout.fragment_profile, container, false); 

     mprofilePic = (CircleImageView) profile.findViewById(R.id.circleImageView_profileimage_profile); 
     mUsername = (TextView) profile.findViewById(R.id.textView_username_profile); 
     mDescription = (TextView)profile.findViewById(R.id.textView_info_profile); 
     mEditProfile = (TextView)profile.findViewById(R.id.textView_editprofile_profile); 
     mSettings = (ImageButton)profile.findViewById(R.id.imageButton_settings_profile); 

     return profile; 
    }   
} 

答えて

0
Firebase.setAndroidContext(getActivity()); 
     Firebase ref = new Firebase(FIREBASE_URL); 
     ref.child("users/0THnm4Tt6WNLm62D2lbtNlzTg2t2/image") 
        .addListenerForSingleValueEvent(new ValueEventListener() { 
         @Override 
         public void onDataChange(DataSnapshot dataSnapshot) { 
          if (dataSnapshot.getValue() != null) { 
           String profilePic = ""; 
           profilePic = (String) dataSnapshot.getValue(); 
           // show image in imageview code 
          } 
         } 

         @Override 
         public void onCancelled(FirebaseError firebaseError) { 
         } 
        }); 
関連する問題