Recycling View Android Plot Becomes Gray After Scrolling
Solution 1:
It looks like you're doing some stuff in the constructor of your ViewHolder
that you probably shouldnt. In particular:
InitDiagramm();
addSampleData();
mPlot.redraw();
RecyclerView
only contains a few View
instances that are dynamically bound to your model data as the user scrolls, which means that you need to set the model data etc. every time the view is bound. This means that addSampleData
and plot.Redraw
should be done in onBindView
.
You have the logic that actually adds the series data mixed between InitDiagramm
and addSampleData
. I'd suggest refactoring that a bit so that your plot style setup is separate from the code that actually sets data on the plot. At the very least, the addSeries
call in InitDiagram
should happen every bind, after your invocation of plot.clear
but before your invocation of plot.redraw
.
Solution 2:
The Problem was that I used the background Thread, after removing the Problem was solved
Before:
<com.androidplot.xy.XYPlot
android:id="@+id/mPlot"
style="@style/APDefacto.Light"
androidplot.renderMode="use_background_thread"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:visibility="visible"
ap:lineLabels="left"
android:minHeight="100dp"/>
After:
<com.androidplot.xy.XYPlot
android:id="@+id/mPlot"
style="@style/APDefacto.Light"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:visibility="visible"
ap:lineLabels="left"
android:minHeight="100dp"/>
Post a Comment for "Recycling View Android Plot Becomes Gray After Scrolling"