android-recyclerview

Detect animation finish in Android's RecyclerView

有些话、适合烂在心里 提交于 2019-12-18 11:41:28
问题 The RecyclerView , unlike to ListView , doesn't have a simple way to set an empty view to it, so one has to manage it manually, making empty view visible in case of adapter's item count is 0. Implementing this, at first I tried to call empty view logic right after modifying underlaying structure ( ArrayList in my case), for example: btnRemoveFirst.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { devices.remove(0); // remove item from ArrayList adapter

Error using the RecyclerView: The specified child already has a parent

流过昼夜 提交于 2019-12-18 11:41:03
问题 I am trying to create a listView with a new RecyvlerView Adapter. I have followed the exact guide present on android developer resources. But this is giving me a strange error: The specified child already has a parent. You must call removeView() on the child's parent first. I have the latest SDK. I also define dependencies in gradle. MyActivity (Main Activity): public class MyActivity extends Activity { private RecyclerView mRecyclerView; private RecyclerView.Adapter mAdapter; private

Store new position of RecyclerView items in SQLite after being dragged and dropped

佐手、 提交于 2019-12-18 11:36:17
问题 I have a two dimensional ArrayList of type String which is the input to the adapter class of the RecyclerView . The data in the list is taken from an SQLite database everytime when onResume() is called. I have implemented a drag and drop feature and an onMove() function that swaps the list elements successfully. However, I need to store the modified list before onResume() is called which will rewrite the list and fill it with old positions. My guess is to implement the rewriting functionality

RecyclerView layoutmanager for changing row and column span

邮差的信 提交于 2019-12-18 11:34:27
问题 I am looking to create the following layout (red sqaures does not really have to be squares, a custom fixed height is also fine). The layout seems very simple yet I did not find a layout manager which suits my needs. I tried the StaggeredGridLayoutManager but this only allows to set the span of either the column or the row, not both. Is there floating around a custom layout manager which is able to do this? I have looked at TwoWayView but changing height seems to be problematic and the

make RecyclerView's height to “wrap_content” in Constraint layout

北城以北 提交于 2019-12-18 10:53:29
问题 i'm trying to set the height of recycler view on wrap_content and make it respect that,but it will exceed the other widget on layout. what can i do now? <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white"> <TextView android:id="@+id/tvPastRounds" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginTop="0dp" android:text="Past

Create Options Menu for RecyclerView-Item

。_饼干妹妹 提交于 2019-12-18 10:16:46
问题 How do I create an Options Menu like in the following Screenshot: The Options Menu should be opened afther clicking on the "More"-Icon of a RecyclerView Item! My try was this: @Override public void onBindViewHolder(Holder holder, int position) { holder.txvSongTitle.setText(sSongs[position].getTitle()); holder.txvSongInfo.setText(sSongs[position].getAlbum() + " - " + sSongs[position].getArtist()); holder.btnMore.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View

RecyclerView.ViewHolder - getLayoutPosition vs getAdapterPosition

我们两清 提交于 2019-12-18 09:54:32
问题 Since the new support library version (22.x) the getPosition() method of the RecyclerView.ViewHolder class has been deprecated in lieu of the methods mentioned in the topic. I don't really get the difference from reading the docs. Could somebody explain the difference in layman's terms? I have the following use case - I give my adapter a List , and also want to be able to associate extra info for each list item. I have a position-to-extra mapping, and the mapping is available for the holders

RecyclerView adds items multiple times

随声附和 提交于 2019-12-18 09:41:26
问题 I use a RecyclerView with a CardLayout and the CardLayout contains multiple components. For filling the RecyclerView I use an Adapter but my problem is, that sometimes when I add new items the item is added multiple times into the RecyclerView . But it is no behavior which is always reproducible (so maybe it has to do with threading?). I don't know the reason :/ I would be very glad for each hint or advice. The code below is a "nearly" working TodoManager, the only problem is the one

android.content.res.Resources$NotFoundException: Resource ID #0x7f07007e

╄→гoц情女王★ 提交于 2019-12-18 08:09:39
问题 I am Trying to implement like feature in the app, here is the snippet from the Viewholder in the recycled view. Recycler customadapter public class PostAdapterViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { TextView title,user,description,tag,time,designation; Long date; ImageView imageView,bookmark,profilepic,sharebutton,like; RelativeLayout head; LinearLayout content; DatabaseReference reference; Context context; String name; public void setContext(Context

Skip items in recycler view

旧时模样 提交于 2019-12-18 07:49:22
问题 Hi I want to skip some items from recyclerview . Here is the bit of code item_Data.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_marginTop="10dp" android:id="@+id/mainlayout" android:layout_height="wrap_content"> <ImageView android:visibility="gone" android:id="@id/image" android:layout_gravity="center" android:layout_width="100dp" android:layout_height="100dp" /> <TextView android