android-recyclerview

Loading large number of items in recycler view

心已入冬 提交于 2019-12-20 20:19:32
问题 I have a recycler view within a fragment and basically I m trying to load song list in the recycler view .Each row of recycler view contains an imageview (for album art) and textview ( for song name). I am having trouble when the size of the dataset is huge, that is when there are too many songs, the recycler view lags and the app ends up giving an ANR.I am using Glide to load album arts in each row's imageview. How is google music player able to show such large number of songs without any

How to sort Strings on an Android RecyclerView?

风格不统一 提交于 2019-12-20 19:37:00
问题 I have a recyclerView full of CardViews that have 2 paramteres (Both of them are Strings), one of those is a title,I would like to have a button to sort them alphabetically based on the tittle. since it doesn't have too many elements I decided to use the insertion sort which is o(n^2) and this is my implementation: public void ISortDes(String[]strings){ int j; String key; int i; for (j = 1; j < strings.length; j++) { key = strings[ j ]; for(i = j - 1; (i >= 0) ; i--) { if (key.compareTo

How do I unit test (with JUnit or mockito) recyclerview item clicks

冷暖自知 提交于 2019-12-20 18:10:13
问题 I am currently trying to unit test recyclerview addonitemclick listner, with either junit or mockito. here's my code: private void mypicadapter(TreeMap<Integer, List<Photos>> photosMap) { List<PhotoListItem> mItems = new ArrayList<>(); for (Integer albumId : photosMap.keySet()) { ListHeader header = new ListHeader(); header.setAlbumId(albumId); mItems.add(header); for (Photos photo : photosMap.get(albumId)) { mItems.add(photo); } pAdapter = new PhotoViewerListAdapter(MainActivity.this, mItems

Kotlin One type argument expected for class for abstract generic view holder

让人想犯罪 __ 提交于 2019-12-20 17:26:30
问题 I'm trying to create a RecyclerView.Adapter with the following: View holders - Provided the abstract parent and one son abstract class BaseSettingsViewHolder<T>(var viewDataBinding : ViewDataBinding) : RecyclerView.ViewHolder(viewDataBinding.root) { abstract fun onBind(data: T, presenter: ISettingsPresenter, position: Int) } class SettingsTitleViewHolder(viewDataBinding: ViewDataBinding) : BaseSettingsViewHolder<TitleData>(viewDataBinding) { override fun onBind(data: TitleData, presenter:

Shared element transition in RecyclerView

雨燕双飞 提交于 2019-12-20 12:29:39
问题 I am trying to use shared element transition on RecyclerView but it doesn't seem to work. This is a part of my adapter in which I use makeSceneTransitionAnimation() : public void onBindViewHolder(final BookViewHolder holder, final int position) { holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(context, DetailsActivity.class); ActivityOptionsCompat optionsCompat = ActivityOptionsCompat

Bounce Effect on RecyclerView

纵饮孤独 提交于 2019-12-20 10:44:35
问题 I want to use a bounce effect on a RecyclerView . A bounce effect whenever I overscroll the content... Does there exist a library or example for it? 回答1: I also couldn't find any library that supports the bounce effect for RecyclerView. Eventually I ended up implementing a new library by myself. Check out my library overscroll-bouncy-android. . It currently supports RecyclerView with LinearLayoutManager. I'm also working on ListView and ScrollView. To use my library: Step 1: dependencies {

RecyclerView item height and width change dynamically Android

给你一囗甜甜゛ 提交于 2019-12-20 10:43:30
问题 I am new to android development and I am developing an app where the app downloads pictures from server and show them in a gridView. But some extra spaces are coming up when the app is run on a bigger screen phone. Here are some screenshots. How do I solve this ? I have the model of each item with a fixed height and width of 110dp My image model : <?xml version="1.0" encoding="utf-8"?> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com

Viewpager not showing inside RecyclerView row

前提是你 提交于 2019-12-20 10:25:09
问题 I want to make a 'Photo details' activity or fragment where i display the photo on top and below it aViewpPager that display both comments and likes of the related photo(2 tabs). In order to make the screen 'Scrollable' so i can scroll up/down on both comments and likes and slide left/right i decided to use a RecyclerView with 2 rows : ROW 1 : The photo (ImageView). ROW 2 : SlidingTabLayout + ViewPager + FragmentPagerAdapter. The code compile and run, display the image and the

RecyclerView + CardView + Touch feedback

萝らか妹 提交于 2019-12-20 10:24:22
问题 Has anybody solved the mystery of the CardView without touch feedback when it's inside a RecyclerView ? I have a RecyclerView with a bunch of CardViews (a CardList ). When I click on any CardView, I start another Activity. That's working pretty fine, but I can't see any touch feedback when I click on the CardView. Just in time, I've already configured my CardView (XML) with these: android:clickable="true" android:background="?android:selectableItemBackground" Thanks! 回答1: Background: The

Display SQLite data in RecyclerView

不打扰是莪最后的温柔 提交于 2019-12-20 10:10:36
问题 I search a lot, but I didn't find any step-by-step guides on how to display SQLite data in RecyclerView. Can anyone explain to me how can I do this? My DataBaseAdapter : public class DataBaseAdapter { DataBaseHelper helper; public DataBaseAdapter(Context context) { helper = new DataBaseHelper(context); } public long insertData(String name, String card, String code) { SQLiteDatabase db = helper.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put