android-viewholder

How can I set OnClickListener to two buttons in RecyclerView?

家住魔仙堡 提交于 2020-07-06 12:02:37
问题 In my android app I have one activity to show a RecyclerView in which each row is composed by a TextView and 2 buttons. Just like that: Well, following many explanations of internet I have made this Adapter: public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ViewHolder> { private LayoutInflater layoutInflater; protected Vector<List> lists; public ListAdapter(Context context, Vector lists) { layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER

how to create one recycler view adapter for multiple viewholders that matches a viewholder of choice not in the same recycler view list

天大地大妈咪最大 提交于 2020-06-28 04:50:22
问题 I would like to know how I can create ONE recycler view adapter that holds MULTIPLE view-holders and each time the RecyclerView is instantiated with that adapter,I want to see only a specific type rather than a mixed type. I have 2 different screens in the Android activity and each of them shows a list of items/cards.One is of text and number and the other is a photo. Right now I have 2 different custom adapters for each object and what I want to achieve is the flexibility of one adapter that

How do iterate through all the views/items in a RecyclerView?

眉间皱痕 提交于 2020-06-26 20:32:17
问题 I need to iterate through all the RadioGroups in my RecyclerView . Code i tried: for(int i=0;i<recyclerView.getAdapter().getItemCount();i++) { radioGroup = recyclerView.findViewHolderForAdapterPosition(i).itemView.findViewById(R.id.radio_group); } but findViewHolderForAdapterPosition(i) returns null for RadioGroups that are off screen and gives me a NullPointerException . How do i iterate through all of them? 回答1: RecyclerView views are created/destroyed as needed when you scroll. You cannot

How to Access an onBindViewHolder item Value from MainActivity in Android

一世执手 提交于 2020-02-06 08:43:25
问题 I have an OnbindViewHolder method in my CarDetailsListAdapter.java file like below @Override public void onBindViewHolder(final CarDetailsListAdapter.ViewHolder viewHolder, final int i) { final CarDetailModel currentItem = getItem(i); Log.e("check", String.valueOf(modelItems)); Log.e("check position", i+" "+currentItem.getCarIsSelected()); // check car min is no cabs or not if(!currentItem.getCarMin().equals("No cabs")) { if (selectcar) { viewHolder.itemView.setSelected(true); //selectedItem

RecyclerView lazy loading

放肆的年华 提交于 2020-01-15 12:15:57
问题 I'm doing lazy loading on a RecyclerView adapter. First I fetch the image metadata (if it has any) and then let Picasso download the actual image. public class PostHolder extends RecyclerView.ViewHolder implements Callback<Photo>{ private PostImageView cover; private TextView content; private long id; public PostHolder(View itemView) { super(itemView); this.itemView.setOnClickListener(onClickListener); content = (TextView) itemView.findViewById(R.id.post_content); cover = (PostImageView)

Android listview behave differently on same kind of device

半城伤御伤魂 提交于 2020-01-15 11:11:49
问题 I'm fighting with a problem that is driving me crazy: I have a very simple ListView which scroll smoothly on a device and very luggy on another device that is almost 100% the same. here you can find a video of the luggy scroll and here you can find a video of the (almost) smooth scrolling. the slow scroll happens on a device with this specs, the smooth scroll happens on a device with this specs here is the very basic code I used (obviously using ViewHolder pattern), how the hell can it be

RecyclerView onBindViewHolder onclicklistener behavior

淺唱寂寞╮ 提交于 2020-01-13 07:06:48
问题 I am trying to load a recycler view that lists cards, each card has four elements. two text views(posttext, score are the id) and two buttons(minusOne and plusOne). The code below loads the textview's content and buttons properly on all cards. I try to implement the following behavior. onbuttonclick of plusOne button, the score will be changed and the minusOne button is hidden. The strange part is, the scores get updated properly on respective cards. But the hiding part appears to happen in

RecyclerView.getChild(index) shows null when list is scrolled (index gets messed up)

谁都会走 提交于 2020-01-10 13:30:31
问题 I've been using SwipeableRecyclerView for my android application for enabling swipes for my recyclerView. RecyclerView contains a list of cardViews. I was trying to implement undo functionality for cards which will get deleted when swipe to left (first swipe shows undo, next swipe triggers delete) I am trying the following code (partially working I guess) SwipeableRecyclerViewTouchListener srvTouchListner = new SwipeableRecyclerViewTouchListener(rvTimerList, new

Smooth scrolling to the next item in list view after radio buttons are selected

你离开我真会死。 提交于 2020-01-06 05:38:06
问题 How to smooth scroll to the next item in the listview after user click on yes or no radio buttons in radio group. For example. If user answered yes or no to the first question it should smooth scroll to the second question. I found the below code and it is working with static position value, but I don't know how to scroll to the next index(next question) on select of radio group(yes or no radio buttons). int index = 0; int h1 = simpleListView.getHeight(); int h2 = simpleListView.getHeight();

Making a ListView holder for MainActivity

喜你入骨 提交于 2020-01-05 13:10:04
问题 I have my listview working to display it on the MainActivity and the layout is set to have 3 TextView properties of a new Person object. My previous code was working but the scrolling was slow, so i looked into using the Holder pattern for optimization. However, when trying to implement this i am getting NullPointerException on lines TextView personID=(TextView) view.findViewById(R.id.person_field1) listView is set to a ListView on the MainActivity and i need the person objects to display on