android-viewholder

What causing this exception java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View]

≯℡__Kan透↙ 提交于 2019-12-01 16:06:18
问题 I'm having a problem with my firebase project. I followed the steps on firebase GitHub documentation, but I got this exception java.lang.RuntimeException: java.lang.NoSuchMethodException: <init> [class android.view.View] this is a ViewHolder class which is not an inner class. 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

onCreateViewHolder of RecyclerView.Adapter is called twice or more, multiple times

别来无恙 提交于 2019-12-01 15:05:52
I'm currently developing an application which uses RecyclerView. On reviewing LogCat I noticed that onCreateViewHolder was called twice after it was instantiated. 09-22 05:22:55.209 V/Adapter﹕ Construct 09-22 05:22:55.213 V/Adapter﹕ onCreateViewHolder 09-22 05:22:55.224 V/Adapter﹕ onBindViewHolder 09-22 05:22:55.240 V/Adapter﹕ onCreateViewHolder 09-22 05:22:55.247 V/Adapter﹕ onBindViewHolder Also onBindViewHolder was called twice though I know it is called whenever the items are recycled. But I think for onCreateViewHolder it is sufficient to be called once. Is this abnormal behavior? If so,

onCreateViewHolder of RecyclerView.Adapter is called twice or more, multiple times

回眸只為那壹抹淺笑 提交于 2019-12-01 13:58:19
问题 I'm currently developing an application which uses RecyclerView. On reviewing LogCat I noticed that onCreateViewHolder was called twice after it was instantiated. 09-22 05:22:55.209 V/Adapter﹕ Construct 09-22 05:22:55.213 V/Adapter﹕ onCreateViewHolder 09-22 05:22:55.224 V/Adapter﹕ onBindViewHolder 09-22 05:22:55.240 V/Adapter﹕ onCreateViewHolder 09-22 05:22:55.247 V/Adapter﹕ onBindViewHolder Also onBindViewHolder was called twice though I know it is called whenever the items are recycled. But

Android DataBinding in RecyclerView.ViewHolders with different layouts

会有一股神秘感。 提交于 2019-12-01 08:27:20
I'm trying to use androids databinding feature in new project and so far very happy with it. But now i came across a problem in my recyclerviews viewholder. My viewholder uses different layouts (based on the viewtype when it gets created) public MediaViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { switch(viewType){ case HEADER: int layout = R.layout.item_media_header; break; case DEFAULT: int layout = R.layout.item_media_default; break; case SMALL: int layout = R.layout.item_media_small; break; } View v = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false);

ViewHolder inflating layout on even and odd position

亡梦爱人 提交于 2019-12-01 00:47:54
I need two layout to inflate on basis of even and odd position of listview items using ViewHolder. At even position I need a different layout and at Odd position another one having same elements but different layout. I implemented it, however, it gives me random layouts at different positions irrespective of their position. What needs to be done to resolve it. Thanks. public SimpleAdapter(ArrayList<WishListData> wishDataList, Context context, ListView swipelistview) { super(context, android.R.layout.simple_list_item_1, wishDataList); notifyDataSetChanged(); SimpleAdapter.wishListData =

RecyclerView Recycled ViewHolder Image View wrong size

流过昼夜 提交于 2019-11-30 20:28:14
I have a recycler view with different View Holders. A couple of view holders have image views which I pass into Glide to display images. The problem is, when the recycler view starts recycling views, the imageview width/height are that of the recycled view they then display the image incorrectly. Here is my ImageView: <ImageView android:id="@+id/image" android:layout_marginTop="@dimen/feed_item_margin" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"/> This is passed into Glide Glide.with(itemView.getContext()) .load(Uri.parse(MediaUtils

ViewHolder inflating layout on even and odd position

半世苍凉 提交于 2019-11-30 19:41:06
问题 I need two layout to inflate on basis of even and odd position of listview items using ViewHolder. At even position I need a different layout and at Odd position another one having same elements but different layout. I implemented it, however, it gives me random layouts at different positions irrespective of their position. What needs to be done to resolve it. Thanks. public SimpleAdapter(ArrayList<WishListData> wishDataList, Context context, ListView swipelistview) { super(context, android.R

Recyclerview with footer not able to delete last item

依然范特西╮ 提交于 2019-11-30 16:43:23
I am using recyclerview with footer everything is working fine. but i am not able to delete last item. Suppose we have 2 products in list now if user will remove one product then 1 product will remain in recyclerview then i am not able to delete that remaining product. While i have one item it shows PACK ID null genericViewHolder.removes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { packid=currentItem.getCart_Product_packid(); System.out.println("PACK ID"+packid); deletetocart(); } }); ADAPTER public class HeaderFooterAdapter extends RecyclerView

Recyclerview with footer not able to delete last item

爱⌒轻易说出口 提交于 2019-11-30 16:14:12
问题 I am using recyclerview with footer everything is working fine. but i am not able to delete last item. Suppose we have 2 products in list now if user will remove one product then 1 product will remain in recyclerview then i am not able to delete that remaining product. While i have one item it shows PACK ID null genericViewHolder.removes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { packid=currentItem.getCart_Product_packid(); System.out.println("PACK

How to call a MainActivity method from ViewHolder in RecyclerView.Adapter?

半城伤御伤魂 提交于 2019-11-30 13:17:17
问题 In a simple app project at GitHub I have only 2 custom Java-files: MainActivity.java contains Bluetooth- and UI-related source code DeviceListAdapter.java contains an Adapter and ViewHolder for displaying Bluetooth devices in a RecyclerView The MainActivity.java contains a method to be called, when user taps on a Bluetooth device in the RecyclerView : public void confirmConnection(String address) { final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); AlertDialog.Builder