recycler-adapter

Recyclerview not updating the data list

五迷三道 提交于 2019-12-24 11:55:45
问题 I'm using recyclerview to display data from sqlite database using cursor , when I delete an item from database the item gets deleted but my recycler view doesn't refresh. I have to go back to my main activity and then the data gets refreshed. I have used notifyItemRemoved() and notifyDataSetChanged() Here is my code. Adapter public class BookmarkAdapter extends RecyclerView.Adapter<BookmarkAdapter.ViewHolder> { public Cursor cursor; DatabaseHelper mDBHelper; public BookmarkAdapter(){ } public

How to load data to recyclerveiw adapter position wise?

点点圈 提交于 2019-12-24 09:57:36
问题 Actually I'm trying to show posts in recyclerview by getting a set of posts from server (mongodb) and it's working fine. Then I'm trying to load post's username by the help of post_ owner_mail .You might say why do I load these things position wise instead of bulk wise but as there will be posts with different ownerMail so it's not possible to prefetch their username. For that purpose I'm using a separate class for loading data from server and showing in text view . But now the problem is the

How to create a interface in main activity and pass the data from adapter to main activity through the interface?

空扰寡人 提交于 2019-12-24 09:16:26
问题 I have created a RecyclerView in my fragment one and I have created a RecyclerViewAdapter to bind my date set to views that are displayed within the RecyclerView in my fragment one. I have loaded my fragment one in my main activity. Now I have a problem is that I need to create an interface in the main activity and pass the data from my adapter to main activity through the interface so that I can wrap the data into bundle and load fragment two. But i do not know how to do this. Can someone

How to implement StackLayoutManager in android Vertical RecyclerView

一笑奈何 提交于 2019-12-24 07:50:45
问题 I want to implement stack of cards from bottom to top swipe each overlap previous card stack.Someone implement this using RecyclerView with custom Layout manager.I don't have enough code. How to do this using Recyclerview. 回答1: Try this way: public class StackLayoutManager extends LinearLayoutManager { public StackLayoutManager(Context context) { super(context); setStackFromEnd(true); } @Override public RecyclerView.LayoutParams generateDefaultLayoutParams() { return new RecyclerView

on click RecyclerView go to another activity with data in android

我的未来我决定 提交于 2019-12-24 01:13:27
问题 i am using RecyclerVeiw to display some images and on click its should start New Activity showing id, name of the RecyclerView. I implemented the code but its now working, its not clickable. below is my adapter import android.content.Context; import android.content.Intent; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com

Change image resource when clicking on ImageView inside the RecyclerView

不羁岁月 提交于 2019-12-23 20:48:08
问题 I'm trying to change my device's image resource inside the recyclerview at the specific position whenever i click at it (click at the image, not the item). I tried to put setOnClickListener() inside the onBindViewHolder() method but only the last item affected. here is my recycler view here is my Adapter: public class Device_RV_Adapter extends RecyclerView.Adapter<Device_View_Holder> { List<Device_Data> list= Collections.emptyList(); Context context; public Device_RV_Adapter(List<Device_Data>

Android issue in selection and deselection of items in an Adapter kotlin?

一世执手 提交于 2019-12-23 16:46:12
问题 I am creating a view to display time in grouping manner. For that I grouped items in an hashmap and passed it to the activity. From my activity, I am initializing the parent adapter to display the list in Linear fashion. In that parent adapter there is another child adapter with times items which are displayed using gridLayout manager in grid fashion. The Image of the current scenario and the issue is as below: Now the actual issue, I want to select only 1 time at a time. But as you see,

Cannot resolve symbol ViewHolder

柔情痞子 提交于 2019-12-23 15:11:02
问题 I was trying to implement a recycler view . but i am not able to use viewHolder . Please find a solution. Thanks in advance 回答1: Try to use just ViewHolder instead of RecyclerView.Adapter.ViewHolder : @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return null; } ... And make sure you have a ViewHolder class inside your adapter class: public class ViewHolder extends RecyclerView.ViewHolder { public ViewHolder(View v) { super(v); } } Hope it helps. 回答2: You can

How to highlight the first row of RecyclerView by default and then remove highlight as and when other rows are selected?

放肆的年华 提交于 2019-12-23 15:03:39
问题 I am trying to load a list in RecyclerView and show the first row of the list as selected. I have achieved it using the following code: @Override public void onBindViewHolder(NavigationDrawerAdapter.ViewHolder holder, final int position) { if (!mNavClassrooms.get(position).equals("")) { holder.mTextViewClassroom.setText(mNavClassrooms.get(position)); // Setting the Text with the array of our Titles holder.mRelLayClassroom.setSelected(mSelectedItems.get(position, false)); /* The following code

Setting the background image of a CardView inside RecyclerView causes the program to crash when scrolling

℡╲_俬逩灬. 提交于 2019-12-23 11:14:14
问题 I have a RecyclerView containing a list of CardViews with information that is pulled from a server, some cards have only a background color but some contains a background image. If the cards all have just background colors, the RecyclerView behaves accordingly (I am able to set the margins and corner radius as well). However, if any one card contains a background image, a crash will happen when I try to scroll up/down the list (although the background image will load without the previously