android-recyclerview

Observer not triggered on room database change

∥☆過路亽.° 提交于 2021-02-09 07:53:45
问题 I am trying to update a RecyclerView when a room database is changed. However the onChanged method of the observer defined in the MainActivity does not get called, when a change to the database occurs. If I let the DAO return LiveData instead of a List<> and use LiveData in my ViewModel it works as intended. However I need MutableLiveData as I want to change my query to the database during runtime. My setup: MainActivity.java BorrowedListViewModel viewModel = ViewModelProviders.of(this).get

How to make the sizes of every item in a RecyclerView different?

ぐ巨炮叔叔 提交于 2021-02-08 19:52:22
问题 I want to achieve something like this: But here's what I get after trying: I already set the height of the layout of the items to WRAP_CONTENT but the result is still the same. What should I do? 回答1: For those who are looking for an answer, just use a StaggeredGridLayoutManager as the RecyclerView 's layout manager like this: recycler.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)); 来源: https://stackoverflow.com/questions/33316293/how-to-make-the-sizes

How to make recycler view start adding items from center?

感情迁移 提交于 2021-02-08 12:20:13
问题 I have a recyclerView with "Horziontal Linear Layout" as layout manager. Recycler View is in a frame layout, with layout_gravity = "center", and layout_width="wrap_content" I want recycler view start adding items from center. Here is what I want: And Here is what I am getting: You can see that in the last image items are added from left. I want it to add items from center as shown in the first three images . 回答1: i had same issue and solved like this for my horizontal RecyclerView: <android

How to delete or remove CardView from RecyclerView? Android Studio

限于喜欢 提交于 2021-02-08 10:33:39
问题 On my RecyclerView are CardViews containing details about a certain exercise and on my CardView, there is an ImageDeleteBtn beside it. How do I delete the CardView from the RecyclerView and on Firebase? This is my Adapter package com.lim.fiture.fiture.adapters; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget

How to delete or remove CardView from RecyclerView? Android Studio

岁酱吖の 提交于 2021-02-08 10:33:29
问题 On my RecyclerView are CardViews containing details about a certain exercise and on my CardView, there is an ImageDeleteBtn beside it. How do I delete the CardView from the RecyclerView and on Firebase? This is my Adapter package com.lim.fiture.fiture.adapters; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget

Updating views of Activity or Fragment from a RecyclerView adapter

旧巷老猫 提交于 2021-02-08 10:30:56
问题 I am trying to update the text in a TextView which is located in the activity to show the total price when an item is deleted from RecyclerView. But how can I update a view which belongs to activity from an adapter? 回答1: Here is the solution. Create a public interface called ItemsInteractionListener which has a method void onTotalPriceChanged(double newPrice); inside adapter Create an object of the interface called mListener inside the adapter Create a public setter for mListener Create a

After Filter a RecyclerView item and clicking it gives wrong item

不想你离开。 提交于 2021-02-08 10:12:52
问题 After performing filtering on Recyclerview items that are fetched through json. It's opening the wrong item when I clicked after filtering the list. Suppose A,B,C,D are in my list, and when I filter for B and click on it - it shows the wrong item (like: A,C,D) but not B. How to fix this? MainActivity.java: public class exit_Activity extends AppCompatActivity implements MyAdapter.OnItemClickListener { String Show_url = "https://retrieve.php"; public static final String EXTRA_ID = "id"; public

Sliding RecyclerView

核能气质少年 提交于 2021-02-08 10:00:24
问题 I have a RecyclerView in a LinearLayout . How can I have LinearLayout "slide" upwards until it hits the App Bar, whereby the RecyclerView should then begin scrolling the items as usual. Likewise, scrolling the list down will begin to "slide" the entire container down when the the first item is reached in the list until the container returns to its starting position. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/container" android:layout_width="match

How to get text from TextView in RecyclerVIew?

偶尔善良 提交于 2021-02-08 07:34:21
问题 I am loading list from MySQL Database to Recycler view using Volley. List is coming to recycler view very smoothly without any problem. But now I want to read question from my recyclervie list. I have implemented Interface to my activity. But when I click on list, it shows nothing. Please help me to do my task. App is showing no error, it just do nothing on list click. Here is my Adapter- public class ProductsAdapter extends RecyclerView.Adapter<ProductsAdapter.ProductViewHolder> { private

Storing list of position in sharedPreferences, and retrieve in another activity

寵の児 提交于 2021-02-08 03:44:53
问题 I want to do similar like this, I have used cardview with recyclerview. I added favourite button cardview below you can see the full code. In recyclerview adapter I print the Toast as per position and its working fine, now I need to save the int value of position in shared Preferences in arraylist and display those arraylist in next intent. This is my recyclerview adapter public void onBindViewHolder(NameViewHolder holder, final int position) { holder.textView.setText(names.get(position)