android-viewholder

How to set two adapters to one RecyclerView?

喜你入骨 提交于 2019-12-03 07:34:52
问题 I am developing an android app in which I'm storing two different types of information on 'FirebaseDatabase`. Then in the MainActivity , I'm retrieving them and showing to users in a RecyclerView . Both information are meant to be shown in different layouts, i.e., the layouts for both of them are different and that's why I have two make two different Model class and now have 2 different adapters. I'm using FastAdapter by @MikePenz So, what I did is I set the adapter on recyclerview in the

Where should I unbind ButterKnife 8.x.x in a ViewHolder?

邮差的信 提交于 2019-12-03 06:38:59
问题 I have a RecycleView.ViewHolder class which use ButterKnife annotations. Should my code unbind() in this ViewHolder class too? public class AView extends RecyclerView.ViewHolder { @BindView(R.id.a_text_view) TextView aText; public AView(final View view) { super(view); ButterKnife.bind(this, view); // It returns an Unbinder, but where should I call its unbind()? } } The docs (http://jakewharton.github.io/butterknife/) does not talk about this issue. 回答1: According to Jake Wharton, author of

Why in ViewHolder pattern should the ViewHolder class be static?

为君一笑 提交于 2019-12-03 04:35:19
I am just trying to have a better understanding of the following pattern I regularly use to optimize ListView My readings only pointed me to the fact that a static inner class is treated as top level class. What is the benefit of such a thing compared to a member class (non static)? @Override public View getView(int position, View convertView, ViewGroup parent) { Comment comment = getItem(position); ViewHolder holder; if (convertView == null){ holder = new ViewHolder(); convertView = LayoutInflater.from(context).inflate(R.layout.mylayout, null); holder.nickname = (TextView) ((ViewGroup)

onBindViewHolder() is never called on view at position even though RecyclerView.findViewHolderForAdapterPosition() returns null at that position

空扰寡人 提交于 2019-12-02 20:28:36
I have a list with 13 items (although items may be added or removed), positions 0-12. When the fragment containing the RecyclerView is first shown, only positions 0 through 7 are visible to the user (position 7 being only half visible). In my adapter I Log every time a view holder is binded/bound (idk if grammar applies here) and record its position. Adapter @Override public void onBindViewHolder(final ViewHolder holder, final int position) { Log.d(TAG, "onBindViewHolder() position: " + position); ... } From my Log I see that positions 0-7 are bound: I have a selectAll() method that gets each

ListView View Holder returning duplicate rows multiple times

ぐ巨炮叔叔 提交于 2019-12-02 19:24:26
问题 Here is my code, View Holder Class : private class ViewHolder { TextView tv1; TextView tv2; TextView tv3; TextView tv4; TextView tv5; TextView tv6; TextView tv7; TextView tv8; TextView tv9; TextView tv10; TextView tv11; TextView tv12; TextView tv13; TextView tv14; EditText edit_qty; Button btnbonus; Button btnremove; } ListView Custom Adapters getView() : @Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder = null; View view = convertView;

Issue with ViewHolder selection

依然范特西╮ 提交于 2019-12-02 14:12:24
I am working in an app in which I handle a ListView which is composite with ViewHolder . In this ViewHolder , I have a CheckBox . Here is my code: private class SettingsArrayAdapter extends ArrayAdapter<Object> { Context context; ArrayList<Object> values; RowSettingsViewHolder vh = null; BigRowSettingsViewHolder bvh = null; @Override public int getItemViewType(int position) { if (values.get(position) instanceof RowContent) { return SMALL_ROW_DESIGN; } else return BIG_ROW_DESIGN; // return super.getItemViewType(position); } @Override public int getViewTypeCount() { return 2; } public

ListView View Holder returning duplicate rows multiple times

一曲冷凌霜 提交于 2019-12-02 09:34:50
Here is my code, View Holder Class : private class ViewHolder { TextView tv1; TextView tv2; TextView tv3; TextView tv4; TextView tv5; TextView tv6; TextView tv7; TextView tv8; TextView tv9; TextView tv10; TextView tv11; TextView tv12; TextView tv13; TextView tv14; EditText edit_qty; Button btnbonus; Button btnremove; } ListView Custom Adapters getView() : @Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder = null; View view = convertView; if(view == null){ view = lInflater.inflate(R.layout.add_productqty_listitem, parent, false); Typeface

How to increment a value on view holder variables in android?

空扰寡人 提交于 2019-12-02 05:15:39
问题 I have a viewholder in my Android app and I tried to set an incremented value on a textfield. I tried it like following, Activity @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { holder = new Holder(); LayoutInflater inflater = (LayoutInflater) this.context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.menu_list_item, null); holder.textViewItemName = (TextView) convertView.findViewById(R

How to Increase or decrease value of edittext in listview's each row?

瘦欲@ 提交于 2019-12-02 02:31:54
I create one Listview , in my Listview I have two Buttons and one Edittext . In my Edittext I want to increase the value of Edittext as per Button 's click. I followed so many tutorials, but still it's not working in my Listview can anyone help me with that? I follow this tutorial: http://www.androidhub4you.com/2013/02/muftitouch-listview-multi-click.html It shows: Cannot refer to the non-final local variable holder defined in an enclosing scope Code: public class UserCustomAdapter extends ArrayAdapter<User> { Context context; int layoutResourceId; ArrayList<User> data = new ArrayList<User>();

GapWorker with Scrapped or attached views may not be recycled. isScrap:false isAttached:true

天涯浪子 提交于 2019-12-01 16:27:09
问题 When i scroll my recyclerview too fast i am getting the following crash java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true at android.support.v7.widget.RecyclerView$Recycler.recycleViewHolderInternal(RecyclerView.java:5659) at android.support.v7.widget.RecyclerView$Recycler.recycleView(RecyclerView.java:5603) at android.support.v7.widget.GapWorker.prefetchPositionWithDeadline(GapWorker.java:277) at android.support.v7.widget