recyclerview

Parent click event not firing when recyclerview clicked

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a RecyclerView which is in a CardView that has a couple of TextViews. The CardView has a OnClickListener set and is fired off when clicking on the TextViews, but does not fire when clicking on the RecyclerView. Here is what the CardView looks like: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_width="match_parent" android:layout_height="match_parent

Android - Kotlin - object must be declared abstract or implement abstract member

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have set an ItemClickLister for my RecyclerView like this: ItemClickSupport.addTo(recyclerView!!).setOnItemClickListener( object : ItemClickSupport.OnItemClickListener { override fun onItemClicked(recyclerView: RecyclerView?, position: Int, v: View?) { val row = recyclerView!!.getChildAt(position) val el = row.findViewById(R.id.active_expandablelayout) as ExpandableLayout if (el.isExpanded) { el.collapse() } else { el.expand() } } } ) using the ItemClickSupport library which I translated into Kotlin. I get an error on object (line 2) that

Android RecyclerView

不羁岁月 提交于 2019-12-03 02:24:18
简介: RecyclerView是support-v7包中的新组件,是一个强大的滑动组件,与经典的ListView相比,同样拥有item回收复用的功能,但是直接把viewholder的实现封装起来,用户只要实现自己的viewholder就可以了,该组件会自动帮你回收复用每一个item。 它不但变得更精简,也变得更加容易使用,而且更容易组合设计出自己需要的滑动布局。 要使用RecyclerView,其实你也可以只下载一个jar包,添加到自己的libs里就能使用它了 使用它的理由: RecyclerView is a more advanced and flexible version of ListView . This widget is a container for large sets of views that can be recycled and scrolled very efficiently. Use the RecyclerView widget when you have lists with elements that change dynamically. 简单说,它是ListView的进化,为了当你需要动态展示一组数据的时候就会需要它。 当然,如果只是动态展示数据,listview也可以做到,用它替代listview的原因有几个:

Android RecyclerView strange endAllStagingAnimators error

匿名 (未验证) 提交于 2019-12-03 02:22:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have very strange problem with displaying item in RecyclerView . first of all it does not display items (strange D/OpenGLRenderer: endAllStagingAnimators on 0x6dd9c400 (CardView) with handle 0x6861d090 appears - never happened before) and back button does not work (it appears but does not react). Ok lets start. I have some Fragment (here is that fragment with RecyclerView : I also have 1 identical fragment to that but one of them conatins as you can see kitchen types and second one has meal types . When I click on one of list items, in

RecyclerView.getChild(index) shows null when list is scrolled (index gets messed up)

匿名 (未验证) 提交于 2019-12-03 02:18:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been using SwipeableRecyclerView for my android application for enabling swipes for my recyclerView. RecyclerView contains a list of cardViews. I was trying to implement undo functionality for cards which will get deleted when swipe to left (first swipe shows undo, next swipe triggers delete) I am trying the following code (partially working I guess) SwipeableRecyclerViewTouchListener srvTouchListner = new SwipeableRecyclerViewTouchListener(rvTimerList, new SwipeableRecyclerViewTouchListener.SwipeListener(){ @Override public boolean

Scrollbar color in RecyclerView

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: How can I change the color of my scrollbar in a recyclerView? I have the scrollbar but I want to change its color. My recyclerView is like this: <android.support.v7.widget.RecyclerView android:layout_width = "match_parent" android:layout_height = "wrap_content" android:id = "@+id/recyclerView" android:layout_below = "@id/my_toolbar" android:layout_above = "@+id/progressBar" android:scrollbars = "vertical" /> 回答1: You can do this by including following line of code in your Recyclerview android:scrollbarThumbVertical="@drawable

RecyclerView: Inner classes cannot have static declaration

匿名 (未验证) 提交于 2019-12-03 02:15:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am a little confused, I have setup a recyclerview as per the tutorial on google/android site and I get the following error Inner classes cannot have static declaration Of course I do have a nested static class but this is how android/google defined it. public class ItemsViewAdapter extends RecyclerView.Adapter<ItemsViewAdapter.ViewHolder> { ... ... public static class ViewHolder extends RecyclerView.ViewHolder { ... } Why i am geting this error, I hear its better to use nested class as a static so you are not wasting a reference but

Get visible items in RecyclerView

匿名 (未验证) 提交于 2019-12-03 02:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to know which elements are currently displayed in my RecyclerView. There is no equivalent to the OnScrollListener.onScroll(...) method on ListViews. I tried to work with View.getGlobalVisibleRect(...) , but that hack is too ugly and does not always work too. Someone any ideas? 回答1: First / last visible child depends on the LayoutManager . If you are using LinearLayoutManager or GridLayoutManager , you can use int findFirstVisibleItemPosition(); int findFirstCompletelyVisibleItemPosition(); int findLastVisibleItemPosition(); int

Use RecyclerView inside ScrollView with flexible Recycler item height

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to know is there any possible way to use RecyclerView ? before this I use RecyclerView with fix height inside a ScrollView but this time i don't know height of the item. Hint : I read all question and solution of stack question before ask this question since 4 days ago. update: some solution learn how to scroll RecyclerView on his own but i want to show this expanded. 回答1: I search for answer this question all over the world but I didn't found any direct answer for this popular question. At last I mixed some trick together

Android Robolectric Click RecyclerView Item

匿名 (未验证) 提交于 2019-12-03 02:07:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there any way to simulate a click on a RecyclerView item with Robolectric? So far, I have tried getting the View at the first visible position of the RecyclerView , but that is always null . It's getChildCount() keeps returning 0 , and findViewHolderForPosition is always null . The adapter returns a non-0 number from getItemCount() (there are definitely items in the adapter). I'm using Robolectric 2.4 SNAPSHOT. 回答1: Seems like the issue was that RecyclerView needs to be measured and layed out manually in Robolectric. Calling this solves