logo
Tags down

shadow

Is there another solutions instead of nested Recyclerview


By : bharath
Date : October 17 2020, 06:10 AM
help you fix your problem Nested Recyclerviews are a bad practice in the material design or google app design guidelines. You will have trouble with a bad and wrong scroll behaviour, it is simply not possible to work with this fluently as a user. Also your views will not be recycled and if your content grows the app will act very slow! There are workarounds but it is all a bad practice and more a bad design. You should inform your customers because there are not aware of those design failures and the technical bottlenecks.
A better way would be to enable to collapse the nested views. And just scroll the whole view or to use paging inside all nested views.
code :


Share : facebook icon twitter icon

In nested recyclerview, child recyclerview's GridLayoutManager.getChildCount() gives total item count


By : liujingzhao
Date : March 29 2020, 07:55 AM
I hope this helps you . Sorry for the late reply. But i will post my solution here if in case someone else is looking for them.
In the adapter of the parent recycler view i have set tag for the view
code :
@Override
public SectionRowHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = mLayoutInflater.inflate(R.layout.view_section, parent, false);
    view.setTag(viewType);
    return new SectionRowHolder(view);
}
public class SectionRowHolder extends RecyclerView.ViewHolder {

    protected RecyclerView recyclerView;
    RecyclerView.OnScrollListener mOnScrollListener;

    public SectionRowHolder(View view) {
        super(view);
        this.recyclerView = (RecyclerView) view.findViewById(R.id.section_list);

    }

    public RecyclerView.OnScrollListener getCustomScrollListener() {
        return mOnScrollListener;
    }

    public void setCustomScrollListener(RecyclerView.OnScrollListener mOnScrollListener) {
        this.mOnScrollListener = mOnScrollListener;
    }
}
 RecyclerView.OnScrollListener scrollListener = new RecyclerView.OnScrollListener() {

        boolean loadEnable = false;

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            mTotalScrolled += dy;
            if ((mTotalScrolled + LOAD_MORE_ENABLE_HEIGHT) > recyclerView.getHeight() && loadEnable) {
                loadEnable = false;
                mLoadMoreListener.loadMore();
            } else {
                loadEnable = true;
            }
        }
    };
    holder.setCustomScrollListener(scrollListener);
    holder.recyclerView.addOnScrollListener(scrollListener);
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);

            View v = mRecyclerView.findViewWithTag(CHILD_RECYCLERVIEW_TAG);
            SectionedLifeAtAdapter.SectionRowHolder viewHolder =
                    (SectionedLifeAtAdapter.SectionRowHolder) mRecyclerView
                            .findContainingViewHolder(v);
            if (viewHolder.getCustomScrollListener() != null)
                viewHolder.getCustomScrollListener().onScrolled((RecyclerView) v
                        .findViewById(R.id.section_list), dx, dy);

            Logger.e(TAG, ">>> call to on scrolled listener >>>");
        }
    });

android nested RecyclerView issue: View.GONE doesn't instantly resize/redraw nested RecyclerView


By : Kibbles
Date : March 29 2020, 07:55 AM
this one helps. Did you to call notifyDataSetChange manually on adapter after removing view?

Add items within nested list within nested recyclerview in a recyclerview


By : user3690962
Date : March 29 2020, 07:55 AM
Does that help We need two RecyclerViews and two Adapters which i call inner and outer.inside ViewHolder of outer adapter put innerRecyclerView and inside onBindViewHolder of outer adapter set adapter to innerRecyclerView.i recently developed a test project like this
here is outerAdapter
code :
public class MainAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

private Context context;
private List<Category> categories;
private List<Ads> ads_list;
private List<Products> productsList;
private int count;
private int width;

public MainAdapter(Context context, List<Category> categories, List<Ads> ads_list,List<Products> productsList,int width) {
    this.context = context;
    this.categories = categories;
    this.ads_list = ads_list;
    this.productsList=productsList;
    this.width=width;
    //Helper.logDebug("main__adapter",String.valueOf(categories.size()));
    //Helper.logDebug("main_adapter","haminjoori");
}

private class ViewHolder extends RecyclerView.ViewHolder{
    private RecyclerView recyclerView;
    private TextView tv_type,ad_tv_image_address;
    private ImageView iv_ad;

    public ViewHolder(@NonNull View itemView) {
        super(itemView);

        recyclerView=itemView.findViewById(R.id.recyclerview_horizental);
        recyclerView.setNestedScrollingEnabled(false);
        tv_type=itemView.findViewById(R.id.tv_type);
        iv_ad=itemView.findViewById(R.id.iv_ad);
        ad_tv_image_address=itemView.findViewById(R.id.ad_image_address);
        //Helper.logDebug("main_adapter","haminjoori");
    }
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    View view= LayoutInflater.from(context).inflate(R.layout.recycler_layout,viewGroup,false);
    //Helper.logDebug("main_adapter","haminjoori");
    return new ViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
    ViewHolder holder= (ViewHolder) viewHolder;
    try {
        String banner_url=ads_list.get(i).getImage();
        holder.ad_tv_image_address.setText(banner_url);
        Picasso.get().load(context.getString(R.string.base_url_banner)+banner_url).into(holder.iv_ad);
    }catch (Exception ex){
        holder.ad_tv_image_address.setText("");
    }
    Helper.logDebug("main_adapter",holder.ad_tv_image_address.getText().toString());
    holder.tv_type.setText(categories.get(i).getName());
    SecondAdapter secondAdapter=new SecondAdapter(categories.get(i).getProducts(),context,width);
    LinearLayoutManager layoutManager=new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false);

    holder.recyclerView.setLayoutManager(layoutManager);
    holder.recyclerView.setAdapter(secondAdapter);



}

@Override
public int getItemCount() {
    return categories.size();
}
}
public class SecondAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

private Context context;
private int count;
private List<Products> productsList;
private List<Category> categories;
private int width;

public SecondAdapter(List<Products> productsList, Context context,int width) {
    this.productsList = productsList;
    this.context = context;
    this.width=width;
}

private class ViewHolder extends RecyclerView.ViewHolder {
    private TextView market_price,our_price,name,unit,min_amount,image;
    private ImageView imagee;
    public ViewHolder(@NonNull View itemView) {
        super(itemView);
        itemView.getLayoutParams().width=width/2;


        market_price=itemView.findViewById(R.id.product_market_price);
        our_price=itemView.findViewById(R.id.product_our_price);
        name=itemView.findViewById(R.id.fruit_name);
        unit=itemView.findViewById(R.id.fruit_unit);
        image=itemView.findViewById(R.id.product_image_url);
        imagee=itemView.findViewById(R.id.iv_rec);
        min_amount=itemView.findViewById(R.id.product_min_amount);

        Log.d("second_adapter","haminjoori");
    }
}

@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
    View view= LayoutInflater.from(context).inflate(R.layout.recycler2_layout,viewGroup,false);
    return new ViewHolder(view);
}

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
    ViewHolder holder= (ViewHolder) viewHolder;
    Helper.logDebug("second_adapter","haminjori");

    holder.name.setText(productsList.get(i).getName());
    holder.unit.setText(productsList.get(i).getUnit());
    holder.market_price.setText(String.valueOf(productsList.get(i).getMarketPrice()));
    holder.our_price.setText(String.valueOf(productsList.get(i).getOurPrice()));
    Helper.logDebug("secondAdapter",productsList.get(i).getImage());
    String address=productsList.get(i).getImage();
    address=address.substring(6);
    holder.image.setText(address);
    String full_address=context.getString(R.string.base_url_image)+address;
    Helper.logDebug("secondAdapter",full_address);
    Picasso.get().load(full_address).into(holder.imagee);
    holder.min_amount.setText(String.valueOf(productsList.get(i).getMin_amount()));
}

@Override
public int getItemCount() {

    Helper.logDebug("second_adapter",String.valueOf(productsList.size()));
    return productsList.size();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools"         
android:layout_height="wrap_content" android:layout_width="match_parent" 
xmlns:android="http://schemas.android.com/apk/res/android">

  <TextView android:layout_height="wrap_content" 
  android:layout_width="wrap_content" android:text="نوع میوه" 
  android:layout_marginBottom="4dp" android:layout_marginTop="4dp" 
  android:layout_centerHorizontal="true" style="@style/main_titles" 
  android:id="@+id/tv_type"/>

  <ImageView android:layout_height="wrap_content" 
  android:layout_width="wrap_content" 
  android:src="@drawable/ic_keyboard_arrow_right_black_24dp" 
  android:layout_alignParentRight="true"/>

  <android.support.v7.widget.RecyclerView 
  android:layout_height="wrap_content" android:layout_width="match_parent" 
  android:id="@+id/recyclerview_horizental" 
  android:layout_below="@id/tv_type" 
  app:layoutManager="android.support.v7.widget.LinearLayoutManager" 
  android:orientation="horizontal" 
  tools:listitem="@layout/recycler2_layout"/>

  <TextView android:layout_height="wrap_content" 
  android:layout_width="wrap_content" android:id="@+id/ad_image_address" 
  android:visibility="gone"/>

  <ImageView android:layout_height="80dp" android:layout_width="match_parent" 
  android:id="@+id/iv_ad" 
  android:layout_below="@id/recyclerview_horizental"/>

  </RelativeLayout>
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:orientation="horizontal" 
android:layout_height="wrap_content" android:layout_width="match_parent" 
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_height="wrap_content" 
android:layout_width="0dp" android:layout_weight="1" 
android:id="@+id/rel_layout">

<ImageView android:layout_height="200dp" android:layout_width="match_parent" 
android:id="@+id/iv_rec"/>

<TextView android:layout_height="wrap_content" 
android:layout_width="wrap_content" android:id="@+id/fruit_name" 
android:textColor="@color/semi_black" android:textSize="14sp" 
android:layout_marginRight="8dp" android:layout_below="@id/iv_rec" 
android:layout_alignParentRight="true" android:text="نام میوه"/>

<TextView android:layout_height="wrap_content" 
android:layout_width="wrap_content" android:id="@+id/fruit_unit" 
android:textColor="@color/black_white" android:textSize="12sp" 
android:layout_below="@id/iv_rec" android:text="واحد" 
android:layout_alignParentLeft="true" android:layout_marginLeft="8dp"/>

<TextView android:layout_height="wrap_content" 
android:layout_width="wrap_content" android:id="@+id/product_market_price" 
android:textColor="@color/semi_black" android:textSize="12sp" 
android:layout_below="@id/fruit_unit" android:text="قیمت مارکت" 
android:layout_alignParentLeft="true" android:layout_marginLeft="8dp"/>

<TextView android:layout_height="wrap_content" 
android:layout_width="wrap_content" android:id="@+id/product_our_price" 
android:textColor="@color/semi_black" android:textSize="12sp" 
android:layout_below="@id/product_market_price" android:text="قیمت ما" 
android:layout_alignParentLeft="true" android:layout_marginLeft="8dp"/>

<TextView android:layout_height="wrap_content" 
android:layout_width="wrap_content" android:id="@+id/product_min_amount" 
android:textColor="@color/semi_black" android:textSize="12sp" 
android:layout_below="@id/product_market_price" 
android:layout_alignParentLeft="true" android:layout_marginLeft="8dp" 
android:visibility="gone"/>

<TextView android:layout_height="wrap_content" 
android:layout_width="wrap_content" android:id="@+id/product_image_url" 
android:textColor="@color/semi_black" android:textSize="12sp" 
android:layout_below="@id/product_market_price" 
android:layout_alignParentLeft="true" android:layout_marginLeft="8dp" 
android:visibility="gone"/>

</RelativeLayout>

<RelativeLayout android:layout_height="wrap_content" 
android:layout_width="0dp" android:layout_weight="1" 
android:visibility="gone"> </RelativeLayout>

</LinearLayout>

RecyclerView with nested RecyclerView - make nested RecyclerView clickable as a whole view


By : rob
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I use a RecyclerView that shows a list of entries. Each entry hosts another RecyclerView that is a list of images. , I looked into RecyclerView source and this helped:

Nested RecyclerView. How to prevent parent RecyclerView from getting scrolled while child RecyclerView is scrolling?


By : Giuseppe La Tona
Date : March 29 2020, 07:55 AM
Hope that helps The problem seemed interesting to me. So I tried to implement and this is what I achieved (you can also see the video here) which is pretty smooth.
Related Posts Related Posts :
  • ARCore for older android devices
  • Could not resolve org.kodein.di:kodein-di-framework-android
  • Exoplayer playback error after interstitial ad
  • Custom lint rule for the `when condition` check
  • Is there a way to know when an app uses a permission in real time?
  • Unsupported Modules Detected: Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one pro
  • Android-studio 3.4.0-3.4.2 Gradle ERROR: No value has been specified for property 'manifestOutputDirectory'
  • Emulator not able to run on MacOs. Emulator claims that OS is out of date
  • How to start socket.io like foreground service to stay connected and listen for messages
  • How to display Snackbar above BottomNavigationView & move FAB?
  • how to prevent recyclerview auto scroll to bottom when insert new items?
  • React native - Make sure your bundle is packaged correctly or you're running a packager server release mode
  • UI doesn't update until tap on the screen when setState is called inside a realm listener callback
  • Android XML binding of MutableLiveData not working
  • How to make textinputedittext editable and uneditable programmatically
  • Can't load Kernel binary: Invalid kernel binary format version. No active package webdev
  • What is the use of {@url} in actions.xml app action URL templates?
  • How to implement device stored card(ios & android) to pay for application?
  • Is it good practice implementing Parcelable on a Room database entity?
  • What is the correct way of starting and stopping camera using CameraX?
  • Android: Add support for in-app updates in application
  • Can I record video with CameraX (Android Jetpack)?
  • Resources task gives error and appcompat-v7 is not loaded
  • Android CameraX doesn't show anything
  • XML constraint layout: Elements placed on top of each other, fix?
  • Flutter - dynamic height on a tab
  • With Scoped Storage introduced in Android Q, how am I supposed to develop a file manager app?
  • Can't resolve symbol android.support.v4.util.Pools in react-native-gesture-handler
  • Jetpack Compose: Could not set unknown property 'useIR'
  • SQLiteException: file is not a database while upgrading sqlcipher version from 3 to 4
  • What are best practices of implementing user login session in android application?
  • Button text not aligned center vertically in react native
  • "flutter (os error: no address associated with hostname, errno = 7)" only for android
  • How to catch platformException in flutter/dart?
  • Unable to connect to ADB
  • How can I test In-app updates in Android?
  • How to apply multiple generics in a function using Kotlin
  • Gradle DSL method not found: 'kapt()'
  • Android ADB: How to push multiple files, into an emulator?
  • How to run a multiple AND query with Android Room?
  • How do i fix the getting null location value from FusedLocationProviderClient in android
  • Which ad formats uses tinder?
  • How to perform delete api in retrofit
  • AWS AppSync Error - AWSMobileClientStore.get(String) on null object reference
  • How to make back button on WebView work in onBackPressed?
  • Circular reference error in firebase with R8
  • how can I move views on the right direction in constrainlayout
  • Send Intent From Activity To Fragment
  • findViewById with PhotoView library problem
  • Removing the bottom Padding from a TextView while using HTML Format
  • Defining resValue conditionally in build.gradle
  • Firebase + Flutter - Cloud functions onCall result in "unauthenticated" error from Android app
  • How to change textview text on cardview click?
  • App crash on opening document for some devices
  • How to fix Android compatibility warnings
  • Can't override android color resources
  • How add menu item's only for debug build type
  • RecyclerView with CardView Items, notifyItemChanged and shadow problem
  • Start activity without click on push notification's item
  • Checking if kapt uses incremental annotation processing
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk