recyclerview

【Debug-singleLine】android:singleLine="true"已被废弃问题

穿精又带淫゛_ 提交于 2019-12-03 01:32:46
Bug描述 有一个界面,外层是ViewPager,内层嵌了一个RecyclerView。RecyclerView有自己的点击和滑动事件,造成外层的ViewPager无法左右滑动。 山重水复 尝试了很多方法,比如可能是外层的ViewPager和内层的RecyclerView有滑动冲突的问题。于是想方设法拦截其中的某项事件监听,但并无卵用。最后折腾半天无果,无奈,按照项目的写法逻辑重新实现了一遍,发现没有发生滑动冲突。 日了狗了。 感觉问题并不在于此。 柳暗花明 逐层查找,从ViewPager的Activity查找到ViewPager每个页面所显示的Fragment的编码,该Fragment的布局文件是一个RecyclerView,查一下该RecyclerView的适配器Adapter,码神保佑,我注意到了其中的【 onCreateViewHolder() 】找到其关联的布局文件,进去看一眼,好神奇,竟然是一个 TextView 。 问题解决 里面用到了一个属性 android:singleLine="true" 这个属性已被谷歌废弃,替换成 android:lines="1" android:ellipsize="end" 问题解决。 参考: https://blog.csdn.net/ldqsxsl/article/details/68485514 总结 1。在TextView中

RecyclerView smoothScroll to position in the center. android

匿名 (未验证) 提交于 2019-12-03 01:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i am using horizontal layout manager for my recyclerView. I need make recyclerView in next way: when click on some item - make smoothScrool to that position and put tat item in the center of recyclerView (if it possible, for example 10 item from 20). so i have no problem with smoothScrollToPosition, but how to put item than in the center of RecyclerView??? thanks! 回答1: Yes it's possible By implements RecyclerView.SmoothScroller's method 'onTargetFound'. /** * Called when the target position is laid out. This is the last callback

failed to resolve com.android.support:appcompat-v7:22 and com.android.support:recyclerview-v7:21.1.2

匿名 (未验证) 提交于 2019-12-03 01:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I installed ALL Extra and SDK API 21-22 including changed compileSdkVersion 22 to 21 buildToolsVersion '22.0.1' to 21.1.2 but error. And Rendering Problems for API 22 and I changed to 回答1: These are the correct version that you can add in your build.gradle according to the API needs. API 24: compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:recyclerview-v7:24.2.1' API 25: compile 'com.android.support:appcompat-v7:25.4.0' compile 'com.android.support:recyclerview-v7:25.4.0' API 26: compile 'com.android.support

recyclerview No adapter attached; skipping layout

匿名 (未验证) 提交于 2019-12-03 01:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Just implemented Recyclerview in my code, replacing Listview. everything works fine. The objects are displayed. but logcat says 15:25:53.476 E/RecyclerView: No adapter attached; skipping layout 15:25:53.655 E/RecyclerView: No adapter attached; skipping layout for the code ArtistArrayAdapter adapter = new ArtistArrayAdapter(this, artists); recyclerView = (RecyclerView) findViewById(R.id.cardList); recyclerView.setHasFixedSize(true); recyclerView.setAdapter(adapter); recyclerView.setLayoutManager(new LinearLayoutManager(this)); As you can see

Swipe to Dismiss for RecyclerView

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I used to SwipeToDismiss library but now I'm trying to migrate to RecyclerView and things are not so obvious, do you know any replacements for this lib? Any ideas how to implement it from the scratch? 回答1: As of v22.2.0, the Android support team has included an ItemTouchHelper class that makes swipe-to-dismiss and drag-and-drop pretty simple. This may not be as full-featured as some of the libraries out there, but it comes directly from the Android team. Update your build.gradle to import v22.2.+ of the RecyclerView library compile 'com

Nested Recycler view height doesn't wrap its content

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an application that manage collections of books (like playlists). I want to display a list of collection with a vertical RecyclerView and inside each row, a list of book in an horizontal RecyclerView. When i set the layout_height of the inner horizontal RecyclerView to 300dp, it is displayed correctly but when i set it to wrap_content, it doesn't display anything. I need to use wrap_content because I want to be able to change the layout manager programmatically to switch between vertical and horizontal display. Do you know what i'm

Android 5.0 - Add header/footer to a RecyclerView

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I spent a moment trying to figure out a way to add a header to a RecyclerView , unsuccessfully. This is what I got so far: @Override protected void onCreate(Bundle savedInstanceState) { ... layouManager = new LinearLayoutManager(getActivity()); recyclerView.setLayoutManager(layouManager); LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); headerPlaceHolder = inflater.inflate(R.layout.view_header_holder_medium, null, false); layouManager.addView(headerPlaceHolder, 0); ... } The

Binary XML file line : Error inflating class <unknown>

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting Error inflating class error in Android 6.0 emulators when I am trying to add foreground drawable. My logcat : Process: com.yasinkacmaz.myapp, PID: 12789 android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at com.yasinkacmaz.myapp.adapter.NoteAdapter.onCreateViewHolder(NoteAdapter.java:86) at android.support.v7.widget.RecyclerView$Adapter

Get visible items in RecyclerView

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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

Recyclerview with multiple countdown timers causes flickering

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to show how much time is left inside each cell of my RecyclerView ...for that I have used a countdown timer for each. In each row I start a counter and manage onTick() ...all works as expected...I've got a timer tick for each row and my cell is also updating but my cell is flickering now....and it goes crazy when I scroll. Here is my adapter... if (product.getProductType().equalsIgnoreCase("Auction Product")) { isAuction=true; viewHolder.img_product_type.setImageResource(R.drawable.bid); viewHolder.txt_timeleft.setVisibility(View