diff --git a/app/src/main/java/org/gateshipone/malp/application/adapters/OutputAdapter.java b/app/src/main/java/org/gateshipone/malp/application/adapters/OutputAdapter.java index f6a968aa..b02cac6c 100644 --- a/app/src/main/java/org/gateshipone/malp/application/adapters/OutputAdapter.java +++ b/app/src/main/java/org/gateshipone/malp/application/adapters/OutputAdapter.java @@ -49,8 +49,14 @@ public View getView(int position, View convertView, ViewGroup parent) { int outputId = output.getID(); boolean active = output.getOutputState(); - - convertView = new OutputListItem(mContext, outputName, active, outputId); + if ( convertView == null ) { + // Create a new View and not reuse it + convertView = new OutputListItem(mContext, outputName, active, outputId); + } else { + OutputListItem outputItem = (OutputListItem)convertView; + outputItem.setName(outputName); + outputItem.setChecked(active); + } return convertView; } diff --git a/app/src/main/java/org/gateshipone/malp/application/listviewitems/OutputListItem.java b/app/src/main/java/org/gateshipone/malp/application/listviewitems/OutputListItem.java index 96d42943..81b21fa3 100644 --- a/app/src/main/java/org/gateshipone/malp/application/listviewitems/OutputListItem.java +++ b/app/src/main/java/org/gateshipone/malp/application/listviewitems/OutputListItem.java @@ -47,4 +47,12 @@ public OutputListItem(Context context, String outputName, boolean active, int ou mMainView.setChecked(active); } + public void setName(String name) { + mMainView.setText(name); + } + + public void setChecked(boolean checked) { + mMainView.setChecked(checked); + } + }