Firebase RecyclerView 图像未显示,其余信息为

Firebase RecyclerView Image not showing, rest of the information is

在我的 activity class 上,RecyclerView 成功地从 Firebase 的 TextView 中检索信息并显示它,但是图像视图没有使用 Picasso 按需要显示图像。

我已经尝试使用 Piccaso.get().load("image").into() 但它仍然没有显示图像。

activity 的 class 也包含视图持有者是:

public class BeefSamosa extends AppCompatActivity {


   private FirebaseRecyclerAdapter<DataHome, DataHomeViewHolder> firebaseRecyclerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_beef_samosa);
        //Back Button
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Beef Samosa");


        RecyclerView recyclerView = findViewById(R.id.beef_view);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
        Query query = rootRef.child("DataHome");

        FirebaseRecyclerOptions<DataHome> firebaseRecyclerOptions = new FirebaseRecyclerOptions.Builder<DataHome>()
                .setQuery(query, DataHome.class)
                .build();


        firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<DataHome, DataHomeViewHolder>(firebaseRecyclerOptions) {
            @Override
            protected void onBindViewHolder(@NonNull DataHomeViewHolder dataHomeViewHolder, int position, @NonNull DataHome dataHome) {
                dataHomeViewHolder.setDataHome(dataHome);
            }

            @Override
            public DataHomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
                View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.homedetail, parent, false);

                return new DataHomeViewHolder(view);
            }
        };
        recyclerView.setAdapter(firebaseRecyclerAdapter);

    }

    @Override
    protected void onStart() {
        super.onStart();
        firebaseRecyclerAdapter.startListening();
    }

    @Override
    protected void onStop() {
        super.onStop();

        if (firebaseRecyclerAdapter!= null) {
            firebaseRecyclerAdapter.stopListening();
        }
    }


    @Override
    public boolean onOptionsItemSelected (MenuItem item){
        int id = item.getItemId();

        if(id == android.R.id.home){
            //ends the activity
            this.finish();
        }
        return super.onOptionsItemSelected(item);
    }





    //DataHomeViewHolder class

    private class DataHomeViewHolder extends RecyclerView.ViewHolder {

        private TextView  titletext, description, ingredients, directions;
        private ImageView imagetoo;


        DataHomeViewHolder(View itemView){
            super(itemView);
            imagetoo = (ImageView) itemView.findViewById(R.id.imagetoo);
            titletext = itemView.findViewById(R.id.titletext);
            description = itemView.findViewById(R.id.description);
            ingredients = itemView.findViewById(R.id.ingredients);
            directions = itemView.findViewById(R.id.directions);
        }


        void setDataHome(DataHome DataHome) {
            Picasso.get().load("image").into(imagetoo);
            String titleto = DataHome.getTitle();
            titletext.setText(titleto);
            String descriptionto = DataHome.getDescription();
            description.setText(descriptionto);
            String ingredientsto = DataHome.getIngredients();
            ingredients.setText(ingredientsto);
            String directionsto = DataHome.getDirections();
            directions.setText(directionsto);
        }
    }
}

xml 文件是:

<ScrollView

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
tools:context=".Fragments.Home"
android:orientation="vertical"
    android:scrollbars="vertical"
    android:fadeScrollbars="false"

android:background="@color/colorAccent"
    >


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >


        <!-- Image -->
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="140dp"
            android:layout_marginLeft="100dp"
            android:layout_marginTop="0dp"
            android:layout_marginRight="100dp"
            android:id="@+id/imagetoo"
            android:scaleType="centerCrop"
            />



        <!-- Title-->
        <TextView
            android:id="@+id/titletext"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_marginLeft="90dp"
            android:layout_marginTop="30dp"
            android:layout_marginRight="100dp"
            android:textSize="25sp"
            android:textStyle="bold"
            android:textColor="@color/black"
            android:scaleType="fitStart" />


        <View
            android:layout_width="match_parent"
            android:layout_height="4dp"
            android:layout_marginTop="0dp"
            android:layout_marginLeft="0dp"
            android:layout_marginRight="250dp"
            android:background="@color/colorPrimaryDark"
            />

        <!-- Description   -->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:layout_marginLeft="39dp"
            android:text="Description:"
            android:textColor="@color/black"
            android:textSize="25sp"
            android:textStyle="italic" />

        <TextView
            android:id="@+id/description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="25dp"
            android:layout_marginLeft="39dp"
            android:textColor="@color/black"
            android:textSize="21sp"
            android:textStyle="normal" />

        <View
            android:layout_width="wrap_content"
            android:layout_height="4dp"
            android:layout_marginLeft="150dp"
            android:layout_marginRight="150dp"
            android:layout_marginTop="35dp"
            android:layout_gravity="bottom"
            android:background="@color/colorPrimaryDark"
            />

        <!-- Ingredients -->

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:layout_marginLeft="39dp"
            android:text="Ingredients:"
            android:textColor="@color/black"
            android:textSize="25sp"
            android:textStyle="italic" />

        <TextView
            android:id="@+id/ingredients"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="25dp"
            android:layout_marginLeft="39dp"
            android:textColor="@color/black"
            android:textSize="21sp"
            android:textStyle="normal" />

        <View
            android:layout_width="wrap_content"
            android:layout_height="4dp"
            android:layout_marginLeft="150dp"
            android:layout_marginRight="150dp"
            android:layout_marginTop="35dp"
            android:layout_gravity="bottom"
            android:background="@color/colorPrimaryDark"
            />

        <!-- Directions -->

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:layout_marginLeft="39dp"
            android:text="Directions:"
            android:textColor="@color/black"
            android:textSize="25sp"
            android:textStyle="italic" />

        <TextView
            android:id="@+id/directions"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="25dp"
            android:layout_marginLeft="39dp"
            android:textColor="@color/black"
            android:textSize="23sp"
            android:textStyle="normal" />


    </LinearLayout>

</ScrollView>

另一个class是:

public class 数据之家{

public DataHome() {}

public String title ,image, description, ingredients, directions;

public DataHome(String title, String image, String description, String ingredients, String directions){
    this.title = title;
    this.image = image;
    this.description = description;
    this.ingredients = ingredients;
    this.directions= directions;
}

public String getTitle() {
    return title;
}

public String getImage() {
    return image;
}

public String getDescription() {
    return description;
}


public String getIngredients() {
    return ingredients;
}


public String getDirections() {
    return directions;
}

}

.load() 期望您的图像 url。更改此行

Picasso.get().load("image").into(imagetoo);

Picasso.get().load(DataHome.getImage()).into(imagetoo);