Android builders often brush challenges once running with the RecyclerView, a almighty and versatile implement for displaying lists of objects. 1 peculiarly irritating content is the dreaded java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid position holder adapter positionViewHolder
, which appears to plague Samsung gadgets with disproportionate frequence. This objection throws a wrench into the creaseless scrolling education and tin pb to app crashes, negatively impacting person restitution. This station volition dive heavy into the causes of this objection, particularly inside the discourse of Samsung gadgets, and supply actionable options to hole it.
Knowing the IndexOutOfBoundsException successful RecyclerViews
The IndexOutOfBoundsException
arises from a mismatch betwixt the RecyclerView’s inner government and the information it’s making an attempt to show. This frequently happens owed to concurrent modifications of the underlying information piece the RecyclerView is trying to entree oregon hindrance views. Ideate a script wherever the adapter’s information fit modifications—possibly an point is added oregon eliminated—piece the RecyclerView is successful the midst of a structure walk. This mismatch leads to the objection, arsenic the RecyclerView makes an attempt to entree a position holder astatine a assumption that nary longer exists inside the up to date dataset. “A communal origin of this content is modifying the adapter’s information straight connected a inheritance thread,” says Android adept, Jake Wharton. Ever guarantee information modifications are dealt with connected the chief thread.
This job is additional exacerbated connected any Samsung units owed to circumstantial implementations of Android’s rendering pipeline oregon nuances successful however inheritance processes are managed. Knowing this discourse is important for efficaciously debugging and resolving the content.
Communal Causes and Options
Respective elements tin lend to the IndexOutOfBoundsException
. Fto’s research any of the about prevalent causes and their corresponding options.
Information Modification connected Inheritance Threads
Modifying the adapter’s information connected a inheritance thread with out appropriate synchronization is a starring origin of this objection. To resoluteness this, guarantee each information modifications are carried out connected the UI thread utilizing runOnUiThread()
oregon by leveraging Kotlin Coroutines with the Dispatchers.Chief
discourse. This ensures thread condition and prevents inconsistencies betwixt the adapter and the RecyclerView.
Incorrectly Carried out DiffUtil
If you’re utilizing DiffUtil
to cipher and dispatch updates effectively, errors successful its implementation tin besides set off the objection. Treble-cheque that getOldListSize()
and getNewListSize()
instrument the accurate sizes, and that areItemsTheSame()
and areContentsTheSame()
precisely indicate information modifications.
Animations and Point Decorations
Analyzable animations oregon customized point decorations tin typically intrude with the RecyclerView’s format calculations, not directly inflicting the IndexOutOfBoundsException
. Simplify oregon briefly disable these parts to seat if they lend to the job. Guarantee your animations and point decorations grip information modifications gracefully.
Samsung-Circumstantial Concerns
Piece the causes talked about supra are broad, definite nuances connected Samsung units mightiness exacerbate the content. Any Samsung units person antithetic rendering pipelines, arsenic noticed by builders reporting the content much often connected these telephones. This isn’t to opportunity the content is solely a Samsung job, however circumstantial interactions with their customized Android builds might brand it much noticeable.
- Trial completely connected assorted Samsung fashions and Android variations.
- Seek the advice of Samsung developer documentation oregon boards for circumstantial workarounds.
Debugging Strategies
Pinpointing the direct origin tin beryllium difficult. Cautious debugging is indispensable. Logging modifications to the adapter’s information, observing the RecyclerView’s format passes, and utilizing breakpoints to examine the government of the adapter and position holders tin supply invaluable insights.
- Log information adjustments and adapter interactions.
- Examine the RecyclerView’s government throughout structure calculations utilizing the debugger.
- Simplify your adapter logic and format to isolate the job.
Different attack is to wrapper your adapter updates successful a attempt-drawback
artifact, logging the afloat stack hint once the objection happens. This supplies captious discourse for debugging, particularly once the content seems sporadically.
Prevention Methods
Proactive measures tin decrease the hazard of encountering the IndexOutOfBoundsException
. Using strong information dealing with methods, rigorous investigating, and using due libraries tin aid forestall this content from occurring successful the archetypal spot.
1 method is to usage immutable information constructions for your adapter’s information fit. This eliminates the hazard of unintended modifications from another components of your exertion. Kotlin’s information lessons and the Database.copyOf()
relation are adjuvant instruments for reaching immutability.
Larn much astir businesslike RecyclerView implementations.See utilizing a room similar Paging three for ample datasets. It handles information loading and updates effectively, decreasing the probabilities of concurrency points.
Often Requested Questions
Q: Wherefore does this objection look much communal connected Samsung units?
A: Piece the underlying causes are mostly level-agnostic, nuances successful Samsung’s Android builds mightiness exacerbate the content. Variations successful rendering pipelines oregon inheritance procedure direction might brand it much prevalent connected these units.
[Infographic Placeholder: Illustrating the action betwixt RecyclerView, Adapter, and information adjustments]
Dealing with the IndexOutOfBoundsException
inside a RecyclerView tin beryllium difficult. Nevertheless, knowing its base causes, equipped with the options introduced, and prioritizing cautious debugging strategies, you tin conquer this communal Android improvement hurdle. Instrumentality the preventive methods, trial completely, particularly connected assorted Samsung units, and guarantee your codification follows champion practices for information dealing with and UI updates. By taking these steps, you’ll make much sturdy and dependable Android apps, offering a smoother, clang-escaped education for your customers. Research additional discussions and options connected Stack Overflow. Don’t hesitate to leverage on-line sources and assemblage boards similar r/androiddev for aid. By adopting a proactive attack and using disposable instruments, you tin debar this irritating objection and present a increased-choice person education.
Android Builders Documentation connected RecyclerView
Question & Answer :
I person a recycler position that plant absolutely connected each units but Samsung. Connected Samsung, I’m acquire
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid position holder adapter positionViewHolder
once I’m going backmost to the fragment with the recycler position from different act.
Adapter codification:
national people FeedRecyclerAdapter extends RecyclerView.Adapter<FeedRecyclerAdapter.MovieViewHolder> { national static last Drawstring getUserPhoto = APIConstants.BASE_URL + APIConstants.PICTURE_PATH_SMALL; Film[] mMovies = null; Discourse mContext = null; Act mActivity = null; LinearLayoutManager mManager = null; backstage Autobus uiBus = null; int mCountOfLikes = zero; //Constructor national FeedRecyclerAdapter(Film[] films, Discourse discourse, Act act, LinearLayoutManager director) { mContext = discourse; mActivity = act; mMovies = motion pictures; mManager = director; uiBus = BusProvider.getUIBusInstance(); } national void setMoviesAndNotify(Film[] films, boolean movieIgnored) { mMovies = films; int firstItem = mManager.findFirstVisibleItemPosition(); Position firstItemView = mManager.findViewByPosition(firstItem); int topOffset = firstItemView.getTop(); notifyDataSetChanged(); if(movieIgnored) { mManager.scrollToPositionWithOffset(firstItem - 1, topOffset); } other { mManager.scrollToPositionWithOffset(firstItem, topOffset); } } // Make fresh views (known as by format director) @Override national MovieViewHolder onCreateViewHolder(ViewGroup genitor, int viewType) { Position position = LayoutInflater.from(genitor.getContext()) .inflate(R.structure.feed_one_recommended_movie_layout, genitor, mendacious); instrument fresh MovieViewHolder(position); } // Changed contend of all position (known as by format director) @Override national void onBindViewHolder(MovieViewHolder holder, int assumption) { setLikes(holder, assumption); setAddToCollection(holder, assumption); setTitle(holder, assumption); setIgnoreMovieInfo(holder, assumption); setMovieInfo(holder, assumption); setPosterAndTrailer(holder, assumption); setDescription(holder, assumption); setTags(holder, assumption); } // returns point number (referred to as by structure director) @Override national int getItemCount() { instrument mMovies != null ? mMovies.dimension : zero; } backstage void setLikes(last MovieViewHolder holder, last int assumption) { Database<Ground> likes = fresh ArrayList<>(); for(Ground ground : mMovies[assumption].causes) { if(ground.rubric.equals("Appreciated this film")) { likes.adhd(ground); } } mCountOfLikes = likes.measurement(); holder.likeButton.setText(mContext.getString(R.drawstring.similar) + Html.fromHtml(getCountOfLikesString(mCountOfLikes))); last MovieRepo repo = MovieRepo.getInstance(); last int pos = assumption; last MovieViewHolder viewHolder = holder; holder.likeButton.setOnClickListener(fresh Position.OnClickListener() { @Override national void onClick(Position v) { if(mMovies[pos].isLiked) { repo.unlikeMovie(AuthStore.getInstance() .getAuthToken(), mMovies[pos].id, fresh Callback<Film>() { @Override national void occurrence(Film film, Consequence consequence) { Drawable img = mContext.getResources().getDrawable(R.drawable.ic_like); viewHolder.likeButton .setCompoundDrawablesWithIntrinsicBounds(img, null, null, null); if (--mCountOfLikes <= zero) { viewHolder.likeButton.setText(mContext.getString(R.drawstring.similar)); } other { viewHolder.likeButton .setText(Html.fromHtml(mContext.getString(R.drawstring.similar) + getCountOfLikesString(mCountOfLikes))); } mMovies[pos].isLiked = mendacious; } @Override national void nonaccomplishment(RetrofitError mistake) { Toast.makeText(mContext.getApplicationContext(), mContext.getString(R.drawstring.cannot_like), Toast.LENGTH_LONG) .entertainment(); } }); } other { repo.likeMovie(AuthStore.getInstance() .getAuthToken(), mMovies[pos].id, fresh Callback<Film>() { @Override national void occurrence(Film film, Consequence consequence) { Drawable img = mContext.getResources().getDrawable(R.drawable.ic_liked_green); viewHolder.likeButton .setCompoundDrawablesWithIntrinsicBounds(img, null, null, null); viewHolder.likeButton .setText(Html.fromHtml(mContext.getString(R.drawstring.similar) + getCountOfLikesString(++mCountOfLikes))); mMovies[pos].isLiked = actual; setComments(holder, assumption); } @Override national void nonaccomplishment(RetrofitError mistake) { Toast.makeText(mContext, mContext.getString(R.drawstring.cannot_like), Toast.LENGTH_LONG).entertainment(); } }); } } }); } backstage void setComments(last MovieViewHolder holder, last int assumption) { holder.likeAndSaveButtonLayout.setVisibility(Position.GONE); holder.commentsLayout.setVisibility(Position.Available); holder.sendCommentButton.setOnClickListener(fresh Position.OnClickListener() { @Override national void onClick(Position v) { if (holder.commentsInputEdit.getText().dimension() > zero) { CommentRepo repo = CommentRepo.getInstance(); repo.sendUserComment(AuthStore.getInstance().getAuthToken(), mMovies[assumption].id, holder.commentsInputEdit.getText().toString(), fresh Callback<Void>() { @Override national void occurrence(Void debar, Consequence consequence) { Toast.makeText(mContext, mContext.getString(R.drawstring.thanks_for_your_comment), Toast.LENGTH_SHORT).entertainment(); hideCommentsLayout(holder); } @Override national void nonaccomplishment(RetrofitError mistake) { Toast.makeText(mContext, mContext.getString(R.drawstring.cannot_add_comment), Toast.LENGTH_LONG).entertainment(); } }); } other { hideCommentsLayout(holder); } } }); } backstage void hideCommentsLayout(MovieViewHolder holder) { holder.commentsLayout.setVisibility(Position.GONE); holder.likeAndSaveButtonLayout.setVisibility(Position.Available); } backstage void setAddToCollection(last MovieViewHolder holder, int assumption) { last int pos = assumption; if(mMovies[assumption].isInWatchlist) { holder.saveButton .setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_check_green, zero, zero, zero); } last CollectionRepo repo = CollectionRepo.getInstance(); holder.saveButton.setOnClickListener(fresh Position.OnClickListener() { @Override national void onClick(Position v) { if(!mMovies[pos].isInWatchlist) { repo.addMovieToCollection(AuthStore.getInstance().getAuthToken(), zero, mMovies[pos].id, fresh Callback<MovieCollection[]>() { @Override national void occurrence(MovieCollection[] movieCollections, Consequence consequence) { holder.saveButton .setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_check_green, zero, zero, zero); mMovies[pos].isInWatchlist = actual; } @Override national void nonaccomplishment(RetrofitError mistake) { Toast.makeText(mContext, mContext.getString(R.drawstring.movie_not_added_to_collection), Toast.LENGTH_LONG).entertainment(); } }); } other { repo.removeMovieFromCollection(AuthStore.getInstance().getAuthToken(), zero, mMovies[pos].id, fresh Callback<MovieCollection[]>() { @Override national void occurrence(MovieCollection[] movieCollections, Consequence consequence) { holder.saveButton .setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_plus, zero, zero, zero); mMovies[pos].isInWatchlist = mendacious; } @Override national void nonaccomplishment(RetrofitError mistake) { Toast.makeText(mContext, mContext.getString(R.drawstring.cannot_delete_movie_from_watchlist), Toast.LENGTH_LONG).entertainment(); } }); } } }); } backstage Drawstring getCountOfLikesString(int countOfLikes) { Drawstring countOfLikesStr; if(countOfLikes == zero) { countOfLikesStr = ""; } other if(countOfLikes > 999) { countOfLikesStr = " " + (countOfLikes/one thousand) + "Ok"; } other if (countOfLikes > 999999){ countOfLikesStr = " " + (countOfLikes/a million) + "M"; } other { countOfLikesStr = " " + Drawstring.valueOf(countOfLikes); } instrument "<tiny>" + countOfLikesStr + "</tiny>"; } backstage void setTitle(MovieViewHolder holder, last int assumption) { holder.movieTitleTextView.setText(mMovies[assumption].rubric); holder.movieTitleTextView.setOnClickListener(fresh Position.OnClickListener() { @Override national void onClick(Position v) { MovieDetailActivity.openView(mContext, mMovies[assumption].id, actual, mendacious); } }); } backstage void setIgnoreMovieInfo(MovieViewHolder holder, last int assumption) { holder.ignoreMovie.setOnClickListener(fresh Position.OnClickListener() { @Override national void onClick(Position v) { MovieRepo repo = MovieRepo.getInstance(); repo.hideMovie(AuthStore.getInstance().getAuthToken(), mMovies[assumption].id, fresh Callback<Void>() { @Override national void occurrence(Void debar, Consequence consequence) { Film[] newMovies = fresh Film[mMovies.dimension - 1]; for (int i = zero, j = zero; j < mMovies.dimension; i++, j++) { if (i != assumption) { newMovies[i] = mMovies[j]; } other { if (++j < mMovies.dimension) { newMovies[i] = mMovies[j]; } } } uiBus.station(fresh MoviesChangedEvent(newMovies)); setMoviesAndNotify(newMovies, actual); Toast.makeText(mContext, mContext.getString(R.drawstring.movie_ignored), Toast.LENGTH_SHORT).entertainment(); } @Override national void nonaccomplishment(RetrofitError mistake) { Toast.makeText(mContext, mContext.getString(R.drawstring.movie_ignored_failed), Toast.LENGTH_LONG).entertainment(); } }); } }); } backstage void setMovieInfo(MovieViewHolder holder, int assumption) { Drawstring imdp = "IMDB: "; Drawstring sources = "", day; if(mMovies[assumption].showtimes != null && mMovies[assumption].showtimes.dimension > zero) { int countOfSources = mMovies[assumption].showtimes.dimension; for(int i = zero; i < countOfSources; i++) { sources += mMovies[assumption].showtimes[i].sanction + ", "; } sources = sources.trim(); if(sources.charAt(sources.dimension() - 1) == ',') { if(sources.dimension() > 1) { sources = sources.substring(zero, sources.dimension() - 2); } other { sources = ""; } } } other { sources = ""; } imdp += mMovies[assumption].imdbRating + " | "; if(sources.isEmpty()) { day = mMovies[assumption].releaseYear; } other { day = mMovies[assumption].releaseYear + " | "; } holder.movieInfoTextView.setText(imdp + day + sources); } backstage void setPosterAndTrailer(last MovieViewHolder holder, last int assumption) { if (mMovies[assumption] != null && mMovies[assumption].posterPath != null && !mMovies[assumption].posterPath.isEmpty()) { Picasso.with(mContext) .burden(mMovies[assumption].posterPath) .mistake(mContext.getResources().getDrawable(R.drawable.noposter)) .into(holder.posterImageView); } other { holder.posterImageView.setImageResource(R.drawable.noposter); } holder.posterImageView.setOnClickListener(fresh Position.OnClickListener() { @Override national void onClick(Position v) { MovieDetailActivity.openView(mActivity, mMovies[assumption].id, mendacious, mendacious); } }); if(mMovies[assumption] != null && mMovies[assumption].trailerLink != null && !mMovies[assumption].trailerLink.isEmpty()) { holder.playTrailer.setVisibility(Position.Available); holder.playTrailer.setOnClickListener(fresh Position.OnClickListener() { @Override national void onClick(Position v) { MovieDetailActivity.openView(mActivity, mMovies[assumption].id, mendacious, actual); } }); } } backstage void setDescription(MovieViewHolder holder, int assumption) { Drawstring matter = mMovies[assumption].overview; if(matter == null || matter.isEmpty()) { holder.descriptionText.setText(mContext.getString(R.drawstring.no_description)); } other if(matter.dimension() > 200) { matter = matter.substring(zero, 196) + "..."; holder.descriptionText.setText(matter); } other { holder.descriptionText.setText(matter); } last int pos = assumption; holder.descriptionText.setOnClickListener(fresh Position.OnClickListener() { @Override national void onClick(Position v) { MovieDetailActivity.openView(mActivity, mMovies[pos].id, mendacious, mendacious); } }); } backstage void setTags(MovieViewHolder holder, int assumption) { Database<Drawstring> tags = Arrays.asList(mMovies[assumption].tags); if(tags.dimension() > zero) { CastAndTagsFeedAdapter adapter = fresh CastAndTagsFeedAdapter(tags, mContext, ((FragmentActivity) mActivity).getSupportFragmentManager()); holder.tags.setItemMargin(10); holder.tags.setAdapter(adapter); } other { holder.tags.setVisibility(Position.GONE); } } // people position holder that supply america a nexus for all component of database national static people MovieViewHolder extends RecyclerView.ViewHolder { TextView movieTitleTextView, movieInfoTextView, descriptionText, reasonsCountText; TextView reasonText1, reasonAuthor1, reasonText2, reasonAuthor2; EditText commentsInputEdit; Fastener likeButton, saveButton, playTrailer, sendCommentButton; ImageButton ignoreMovie; ImageView posterImageView, userPicture1, userPicture2; TwoWayView tags; RelativeLayout mainReasonsLayout, firstReasonLayout, secondReasonLayout, reasonsListLayout; RelativeLayout commentsLayout; LinearLayout likeAndSaveButtonLayout; ProgressBar progressBar; national MovieViewHolder(Position position) { ace(position); movieTitleTextView = (TextView)position.findViewById(R.id.movie_title_text); movieInfoTextView = (TextView)position.findViewById(R.id.movie_info_text); descriptionText = (TextView)position.findViewById(R.id.text_description); reasonsCountText = (TextView)position.findViewById(R.id.reason_count); reasonText1 = (TextView)position.findViewById(R.id.reason_text_1); reasonAuthor1 = (TextView)position.findViewById(R.id.author_1); reasonText2 = (TextView)position.findViewById(R.id.reason_text_2); reasonAuthor2 = (TextView)position.findViewById(R.id.author_2); commentsInputEdit = (EditText)position.findViewById(R.id.comment_input); likeButton = (Fastener)position.findViewById(R.id.like_button); saveButton = (Fastener)position.findViewById(R.id.save_button); playTrailer = (Fastener)position.findViewById(R.id.play_trailer_button); sendCommentButton = (Fastener)position.findViewById(R.id.send_button); ignoreMovie = (ImageButton)position.findViewById(R.id.ignore_movie_imagebutton); posterImageView = (ImageView)position.findViewById(R.id.poster_image); userPicture1 = (ImageView)position.findViewById(R.id.user_picture_1); userPicture2 = (ImageView)position.findViewById(R.id.user_picture_2); tags = (TwoWayView)position.findViewById(R.id.list_view_feed_tags); mainReasonsLayout = (RelativeLayout)position.findViewById(R.id.reasons_main_layout); firstReasonLayout = (RelativeLayout)position.findViewById(R.id.first_reason); secondReasonLayout = (RelativeLayout)position.findViewById(R.id.second_reason); reasonsListLayout = (RelativeLayout)position.findViewById(R.id.reasons_list); commentsLayout = (RelativeLayout)position.findViewById(R.id.comments_layout); likeAndSaveButtonLayout = (LinearLayout)position .findViewById(R.id.like_and_save_buttons_layout); progressBar = (ProgressBar)position.findViewById(R.id.centered_progress_bar); } } }
Objection:
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid position holder adapter positionViewHolder{42319ed8 assumption=1 id=-1, oldPos=zero, pLpos:zero scrap tmpDetached nary genitor} astatine android.activity.v7.widget.RecyclerView$Recycler.validateViewHolderForOffsetPosition(RecyclerView.java:4166) astatine android.activity.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4297) astatine android.activity.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4278) astatine android.activity.v7.widget.LinearLayoutManager$LayoutState.adjacent(LinearLayoutManager.java:1947) astatine android.activity.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:434) astatine android.activity.v7.widget.LinearLayoutManager.enough(LinearLayoutManager.java:1322) astatine android.activity.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:556) astatine android.activity.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:171) astatine android.activity.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2627) astatine android.activity.v7.widget.RecyclerView.onLayout(RecyclerView.java:2971) astatine android.position.Position.structure(Position.java:15746) astatine android.position.ViewGroup.structure(ViewGroup.java:4867) astatine android.activity.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:562) astatine android.position.Position.format(Position.java:15746) astatine android.position.ViewGroup.structure(ViewGroup.java:4867) astatine android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) astatine android.widget.FrameLayout.onLayout(FrameLayout.java:388) astatine android.position.Position.structure(Position.java:15746) astatine android.position.ViewGroup.structure(ViewGroup.java:4867) astatine android.activity.v4.position.ViewPager.onLayout(ViewPager.java:1626) astatine android.position.Position.format(Position.java:15746) astatine android.position.ViewGroup.format(ViewGroup.java:4867) astatine android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677) astatine android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531) astatine android.widget.LinearLayout.onLayout(LinearLayout.java:1440) astatine android.position.Position.format(Position.java:15746) astatine android.position.ViewGroup.format(ViewGroup.java:4867) astatine android.activity.v4.position.ViewPager.onLayout(ViewPager.java:1626) astatine android.position.Position.format(Position.java:15746) astatine android.position.ViewGroup.format(ViewGroup.java:4867) astatine android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677) astatine android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531) astatine android.widget.LinearLayout.onLayout(LinearLayout.java:1440) astatine android.position.Position.structure(Position.java:15746) astatine android.position.ViewGroup.format(ViewGroup.java:4867) astatine android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) astatine android.widget.FrameLayout.onLayout(FrameLayout.java:388) astatine android.position.Position.structure(Position.java:15746) astatine android.position.ViewGroup.format(ViewGroup.java:4867) astatine android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677) astatine android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531) astatine android.widget.LinearLayout.onLayout(LinearLayout.java:1440) astatine android.position.Position.structure(Position.java:15746) astatine android.position.ViewGroup.structure(ViewGroup.java:4867) astatine android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) astatine android.widget.FrameLayout.onLayout(FrameLayout.java:388) 07-30 12:forty eight:22.688 9590-9590/com.Filmgrail.android.debug W/Scheme.err? astatine android.position.Position.structure(Position.java:15746) astatine android.position.ViewGroup.format(ViewGroup.java:4867) astatine android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677) astatine android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531) astatine android.widget.LinearLayout.onLayout(LinearLayout.java:1440) astatine android.position.Position.structure(Position.java:15746) astatine android.position.ViewGroup.structure(ViewGroup.java:4867) astatine android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) astatine android.widget.FrameLayout.onLayout(FrameLayout.java:388) astatine android.position.Position.structure(Position.java:15746) astatine android.position.ViewGroup.format(ViewGroup.java:4867) astatine android.position.ViewRootImpl.performLayout(ViewRootImpl.java:2356) astatine android.position.ViewRootImpl.performTraversals(ViewRootImpl.java:2069) astatine android.position.ViewRootImpl.doTraversal(ViewRootImpl.java:1254) astatine android.position.ViewRootImpl$TraversalRunnable.tally(ViewRootImpl.java:6630) astatine android.position.Choreographer$CallbackRecord.tally(Choreographer.java:803) astatine android.position.Choreographer.doCallbacks(Choreographer.java:603) astatine android.position.Choreographer.doFrame(Choreographer.java:573) astatine android.position.Choreographer$FrameDisplayEventReceiver.tally(Choreographer.java:789) astatine android.os.Handler.handleCallback(Handler.java:733) astatine android.os.Handler.dispatchMessage(Handler.java:ninety five) astatine android.os.Looper.loop(Looper.java:136) astatine android.app.ActivityThread.chief(ActivityThread.java:5479) astatine java.lang.indicate.Methodology.invokeNative(Autochthonal Methodology) astatine java.lang.indicate.Methodology.invoke(Technique.java:515) astatine com.android.inner.os.ZygoteInit$MethodAndArgsCaller.tally(ZygoteInit.java:1283) astatine com.android.inner.os.ZygoteInit.chief(ZygoteInit.java:1099) astatine dalvik.scheme.NativeStart.chief(Autochthonal Methodology)
However tin I hole this?
This job is precipitated by RecyclerView
Information modified successful antithetic thread. The champion manner is checking each information entree. And a workaround is wrapping LinearLayoutManager
.
Former reply
Location was really a bug successful RecyclerView and the activity 23.1.1 inactive not mounted.
For a workaround, announcement that backtrace stacks, if we tin drawback this Objection
successful 1 of any people it whitethorn skip this clang. For maine, I make a LinearLayoutManagerWrapper
and override the onLayoutChildren
:
national people WrapContentLinearLayoutManager extends LinearLayoutManager { //... constructor @Override national void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.Government government) { attempt { ace.onLayoutChildren(recycler, government); } drawback (IndexOutOfBoundsException e) { Log.e("TAG", "just a IOOBE successful RecyclerView"); } } }
Past fit it to RecyclerView
:
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycler_view); recyclerView.setLayoutManager(fresh WrapContentLinearLayoutManager(act, LinearLayoutManager.HORIZONTAL, mendacious));
Really drawback this objection, and appears nary immoderate broadside-consequence but.
Besides, if you usage GridLayoutManager
oregon StaggeredGridLayoutManager
you essential make a wrapper for it.
Announcement: The RecyclerView
whitethorn beryllium successful a incorrect inner government.