Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用滑动将图像添加到工具栏_Java_Android_Imageview_Android Glide - Fatal编程技术网

Java 使用滑动将图像添加到工具栏

Java 使用滑动将图像添加到工具栏,java,android,imageview,android-glide,Java,Android,Imageview,Android Glide,嗨,伙计们,我正在创建一个应用程序,用户可以从选择的化身中选择个人资料图像。化身图像URL存储在firebase数据库中。当用户选择了我希望在工具栏中显示的图像时。所以我觉得这样做会管用的 private void setToolBar(){ ref.child("Users").child(userID).addValueEventListener(new ValueEventListener() { @Override publi

嗨,伙计们,我正在创建一个应用程序,用户可以从选择的化身中选择个人资料图像。化身图像URL存储在firebase数据库中。当用户选择了我希望在工具栏中显示的图像时。所以我觉得这样做会管用的

 private void setToolBar(){
    ref.child("Users").child(userID).addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot snapshot) {
            String profileimage = snapshot.child("OnavatarId").getValue(String.class);
            String profileusername = snapshot.child("OnUsername").getValue(String.class);
             profile_image = mtoolbar.findViewById(R.id.image);

            Glide.with(MainActivity.this).load(profileimage).into(profile_image);

            setSupportActionBar(mtoolbar);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
工具栏xml

<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_app_bar"
android:background="@color/design_default_color_primary">

<de.hdodenhof.circleimageview.CircleImageView
    android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     />


但是没有任何事情发生,请有人帮忙

我想你在
profileimage
url-to-image方面有问题。请确保在加载照片时将
.error(R.drawable.error)
添加到滑动请求中。

在添加R.drawable.error时无法解决错误?可以是项目中显示有错误的任何
drawable
位图
。我的datasnapshot似乎返回为空..hmmok,所以我已将其显示出来。。但现在它出现在全屏上