我正在嘗試使用來(lái)自 firebase 的 Glide 庫(kù)加載圖像。圖片 url 正確(使用 Logcat 檢查)。我在活動(dòng)中使用滑行而不是片段。我收到這個(gè)錯(cuò)誤 java.lang.NullPointerException: You cannot start a load on a not yet attached View or a Fragment where getActivity() returns null (which usually occurs when getActivity() is called before the Fragment is attached or after the Fragment is destroyed).這是我的代碼:public class ProfileActivity extends AppCompatActivity {FirebaseAuth auth;DatabaseReference databaseReference;TextView nameTextView , bioTextView;String name2 , bio2 , uidString;Uri imageUri , FilePathUri;Button logOut , editProfile;private SlidrInterface slidr;CircleImageView profilepic;StorageReference storageReference;String Storage_Path = "ProfilePictures/" , downloadUrl;Context context;@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); auth = FirebaseAuth.getInstance(); databaseReference = FirebaseDatabase.getInstance().getReference(); final FirebaseUser user = auth.getCurrentUser(); nameTextView = (TextView) findViewById(R.id.name); bioTextView = (TextView) findViewById(R.id.bio); logOut = (Button) findViewById(R.id.logout2); editProfile = (Button) findViewById(R.id.editprofile); slidr = Slidr.attach(this); profilepic = (CircleImageView) findViewById(R.id.profilepic); storageReference = FirebaseStorage.getInstance().getReference(); Intent intent = getIntent(); Bundle uid = intent.getExtras(); uidString = uid.getString("UID"); Log.d("UID OF USER" , "UID OF USER = "+uidString); final Context finalContext = context; databaseReference.child("users").child(uidString).addValueEventListener(new ValueEventListener() { }如果我不使用片段,為什么會(huì)出現(xiàn)此錯(cuò)誤。另外我將如何解決這個(gè)錯(cuò)誤。請(qǐng)幫我
無(wú)法使用 Glide 庫(kù)加載圖像
呼啦一陣風(fēng)
2023-03-23 15:19:36