私のfirebase
プロジェクトに問題があります。 私はfirebase
GitHubのマニュアルの手順に従ったが、私はこの例外この例外の原因は何ですか?java.lang.NoSuchMethodException:<init> [クラスandroid.view.View]
java.lang.RuntimeException: java.lang.NoSuchMethodException: <init>
[class android.view.View]
を得た。この内部クラスではありませんViewHolder
クラスです。
public class ProductViewHolder extends RecyclerView.ViewHolder{
public View mView;
public ImageView img;
public TextView title;
public TextView price;
public RatingBar stars;
ProductViewHolder(View itemView) {
super(itemView);
mView = itemView;
img = (ImageView) itemView.findViewById(R.id.productImg);
title = (TextView) itemView.findViewById(R.id.txtTitle);
price = (TextView) itemView.findViewById(R.id.txtPrice);
stars = (RatingBar) itemView.findViewById(R.id.ratingBar);
}
}
、これは私がデータモデル、 とviewHolder
クラスを移入するfirebaseRecyclerView
を使用していfirebase関連のコード
@Override
protected void onStart() {
super.onStart();
// Recycler adapter
FirebaseRecyclerAdapter<Product, ProductViewHolder> adapter =
new FirebaseRecyclerAdapter<Product, ProductViewHolder>(
Product.class,
R.layout.product_list_item,
ProductViewHolder.class,
firebaseRef.child("product")) {
@Override
protected void populateViewHolder(ProductViewHolder productViewHolder, Product product, int i) {
Picasso.with(ShopsApp.getLyShopsAppContext())
.load(product.getImgUrl())
.placeholder(R.drawable.none)
.into(productViewHolder.img);
productViewHolder.title.setText(product.getTitle());
productViewHolder.price.setText(product.getPrice());
productViewHolder.stars.setRating(4.0f);
}
};
recyclerView1.setAdapter(adapter);
ですが、私の活動
注意の内部クラスではありません。例外は、recyclerView
を含むアクティビティが開始されたときに発生します。
下記の2つの原因が考えられます。そうでない場合は、問題を再現できる最小限のコードを含めるように質問してください(http://stackoverflow.com/posts/36972335/edit)。 –
あなたの 'ProductViewHolder'コンストラクタはpublicではありません。 –
問題が解決しました –