recycler-adapter

update RecyclerView with Android LiveData

戏子无情 提交于 2019-12-04 07:50:06
问题 There are many examples how to push new list to adapter on LiveData change. I'm trying to update one row (e.g number of comments for post) in the huge list. It would be stupid to reset whole list to change only one field. I am able to add observer onBindViewHolder, but I can't understand when should I remove observer @Override public void onBindViewHolder(ViewHolder vh, int position) { Post post = getPost(position); vh.itemView.setTag(post); post.getLiveName().observeForever(vh.nameObserver);

RecyclerView disappearing images

北城以北 提交于 2019-12-04 04:26:18
What I am trying to create is a horizontal scrolling image gallery. I have a RecyclerView (support 22.0.0). The problem I am having is that when I scroll to the end and then scroll back, usually one image will be missing sometimes two. Strangely when I keep swiping back and forth, a different image could be missing. Here is the layout for the item: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="160dp"> <ImageView android:id="@+id/product_variation_image" android:layout_width="match_parent" android:layout_height

Double Click OnClickListener of a Recycler View Adapter

浪子不回头ぞ 提交于 2019-12-04 04:22:29
I am trying to add a simple Click View to an item of a recycler view, but for some reason I have to click on an item twice instead of once to perform an action. On single click it seems like that recycler View does not detect a click. On the next one however it detects the click and performs a suitable action. XML : <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/cardView" android:layout_width="match_parent" android:layout_height="wrap_content" > <RelativeLayout android:id="@+id/rlContainer" android:layout_width="match_parent"

Recycler View Fatal Exception: java.lang.ArrayIndexOutOfBoundsException

天涯浪子 提交于 2019-12-04 03:34:49
I have got this stack trace though crashlytics. I have no idea where the issue is. Is there any alternative of StaggeredGridLayoutManager that I can use to get a listview like layout. Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: start < 0 || end > len. start=-1, end=11, len=11 at java.util.Arrays.checkStartAndEnd(Arrays.java:1745) at java.util.Arrays.fill(Arrays.java:803) at android.support.v7.widget.StaggeredGridLayoutManager$LazySpanLookup.invalidateAfter(SourceFile:2404) at android.support.v7.widget.StaggeredGridLayoutManager.handleUpdate(SourceFile:1373) at android.support.v7

Android : Change cart menu badge counter from Recycler Adapter

前提是你 提交于 2019-12-03 21:39:18
I am trying to develop e-commerce type of app in which user can add item to cart. But I am unable to update the cart badge counter from adapter. Here is screenshot of my app. I am using Recycler view inside fragment. And I am referring this below link for menu item count. https://mobikul.com/adding-badge-count-on-menu-items-like-cart-notification-etc/ My problem is I cannot access menu item from adapter. Here is my fragment code. PriceListFragment.java public class PriceListFragment extends Fragment { public ArrayList<Design> designList; private Single_DesignAdapter adapter; private

Android: how can I insert a RecyclerView inside CardView?

可紊 提交于 2019-12-03 18:49:38
问题 The activity I am talking about must show a RecyclerView populated by CardViews as items. My goal is to show in every CardView a RecyclerView in its turn. Here my Activity's basic xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ConjActivity" > <android.support.v7.widget.RecyclerView android

Error inflating class RecyclerView

萝らか妹 提交于 2019-12-03 18:00:38
问题 So my code simply makes a list of CardViews using RecyclerView. Upon running my code i kept getting a weird error claiming there was an error in my xml. After tinkering for a while i found out that in my layout file if i change <RecyclerView> to <android.support.v7.widget.RecyclerView> everything would work just fine. Why is this happening? My activity. import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import

RecyclerView corrupts view using notifyItemMoved()

本小妞迷上赌 提交于 2019-12-03 12:50:01
I'm having a problem with using the notifyItemMoved() method. It seems to be incorrectly displaying unmoved views. My list has 4 element in it. What I want to do is animate a swap between item 1 and item 3. Items 1 and 3 swap correctly, but item 2 displays what was at item 3! So the list starts off looking something like this: Item 0 Item 1 Item 2 Item 3 And ends like this: Item 0 Item 3 Item 3 <!-- What the heck has this changed for? Item 1 My adapter is backed by a List mProductList . I call the following code: public void sortBackingListUsingSortingList(List<ProductWrapper> newProductItems)

How to show part of next/previous card RecyclerView

妖精的绣舞 提交于 2019-12-03 12:10:36
What is the best strategy to achieve this feature: I Have a horizontal RecyclerView with cards. Each card will fulfil the entire screen, but I want it to show part of the next card and previous one if it has more than one item. I know I can achieve this by setting my card android:layout_width at the adapter to have a specific DP like 250dp instead of match_parent . But it doesn't look like a proper solution. This is my code: Activity with RecyclerView: class ListPokemon : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)

Recyclerview item click ripple effect [duplicate]

泪湿孤枕 提交于 2019-12-03 11:33:50
问题 This question already has answers here : Adding Ripple Effect to RecyclerView item (4 answers) Closed last year . I am trying to add Ripple Effect to RecyclerView 's item. I had a look online, but could not find what I need. I have tried android:background attribute to the RecyclerView itself and set it to "?android:selectableItemBackground" but it did not work.: My Parent layout is like this <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android