android-recyclerview

Encountering lag when updating a CardView item in a RecycleView

旧巷老猫 提交于 2019-12-13 01:37:50
问题 i'm having an issue working with CardViews . I`ve created a CardView containing 1 TextView and 2 ImageViews , which gets displayed in an RecycleView . When i try to update the contents of one of the CardViews (created 5 cards for testing) the interface starts to lag when scrolling over the updated card, but goes back to normal when i pass the item. It only happens when ImageViews are present , when substituting the ImageViews for say, TextViews with some random text in them, it works normally

RecyclerView scroll to position and get that view

核能气质少年 提交于 2019-12-13 01:28:35
问题 I want to auto scroll a list item to top (firstVisible item) in my recycler view and get the view at that position, so I can highlight it, from my fragment. So, this is the gist of my fragment code : private void activateNewListItem(int position) { mLayoutManager().scrollToPositionWithOffset(position, 0); RecyclerView.ViewHolder viewHolder = mRecyclerView.findViewHolderForLayoutPosition(position); View view = viewHolder.getItemView(); view.setBackgroundColor(getResources().getColor(R.color

Android Recycler view Scroll bar

左心房为你撑大大i 提交于 2019-12-13 01:27:53
问题 How to get scroll bar in recycler view ? I am developing an Image gallery application where images are loaded in recycler view. So I want a have a scroll bar where while scrolling date of capture can be shown. Somewhat similar to this (date instead of letters):- 回答1: This blog post by Mark Allison should be exactly what you're looking for. 来源: https://stackoverflow.com/questions/36482762/android-recycler-view-scroll-bar

RecyclerView hides Toolbar and layout when SoftKeyboard is visible

折月煮酒 提交于 2019-12-13 01:23:25
问题 I've a problem exactly like this LINK, same situation and same components in layouts. The only difference is the toolbar, but obviously i'm using appcompat and the behaviour is the same. Attention, not only the toolbar is hided, but also the upper part of the recyclerview. Is like if the entire fragment is translated up when the softkeyboard is visible. I'm using a toolbar like this in the main.xml of my activity: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http:/

android-recycleview inside scrollview

怎甘沉沦 提交于 2019-12-13 01:12:29
问题 In my activity , I want to put a slideShow above my page and then put recycleview after that, to do so ,I'v written this code in my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fff" android:orientation="vertical" android:padding="6dp"> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res

RecyclerView with null pointer exception

烈酒焚心 提交于 2019-12-13 00:55:17
问题 I am getting some news data from my CMS,and want to display them in a RecyclerView.The problem is that I am getting a null pointer exception in the line where I using the LinearLayoutManager. Here is the logcat output. Caused by: java.lang.NullPointerException at testing.theo.manchesterunitedapp.newsandfeatures.FeaturesFragment.onCreateView(FeaturesFragment.java:65) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962) at android.support.v4.app.FragmentManagerImpl

How to track item selection on recycler view item click?

狂风中的少年 提交于 2019-12-13 00:52:40
问题 I want to highlight the item of recyclerview when user click on any item and previous item will be unselected please help? 回答1: For this you have to write a selector. <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/colorAccent" android:state_selected="true" /> <item android:drawable="@color/ash" android:state_selected="false" /> <item android:drawable="@color/ash" /> </selector> In-order to get the desired behavior on the onClick you have

Espresso - How to click on a random RecyclerView item?

眉间皱痕 提交于 2019-12-13 00:48:32
问题 There are a few posts that show how can you click a certain fixed item in the RecyclerView with Espresso, like: How to click on an item inside a RecyclerView in Espresso Using Espresso to click view inside RecyclerView item Example: //Change the 0 with any other number, will be the position of the item clicked. onView(withId(R.id.a_main_recycler)) .perform(RecyclerViewActions .actionOnItemAtPosition(0, click())); But, what if you want to click on a random item in the RecyclerView? 回答1: Use

Dynamic position of views in RecyclerView

情到浓时终转凉″ 提交于 2019-12-12 23:54:00
问题 My question is based on a previous question about my Code - it's a newsfeed with different views which are scrollable vertically or horizontally or display various content (ads basically) VERTICAL VIEW HORIZONTAL VIEW AD VIEW Now I managed with the help of Ben P, on my previous post to organize my views with the following code: this.items = new ArrayList<>(); if (listVertical.size() > 0) { items.add(listVertical.remove(0)); } if (listHorizontal.size() > 0) { items.add(listHorizontal.remove(0)

how to make thumbnail image with initials two char from name android?

岁酱吖の 提交于 2019-12-12 21:59:02
问题 I want to thumbnail initials with two word for my image view like "Peter Parker" but am able to get only one word "P"while running code how can get second word after space my code is. holder.imgName?.text=teamData[position].userImage.substring(0,1) 回答1: You can do it functional way: val peterParker = "Peter Parker" val initials = peterParker .split(' ') .mapNotNull { it.firstOrNull()?.toString() } .reduce { acc, s -> acc + s } println(initials) //PP This would cover cases when a person's name