I'm trying to get a grid of SmoothCheckboxes (can be found here http://ift.tt/2nnWIcT), and the grid populates with everything I throw at it successfully, besides the SmoothCheckBox itself. What am I doing wrong here?
My Custom Adapter:
public class ExercisesAdapter extends BaseAdapter {
private Context context;
private final SmoothCheckBox[] checkboxes;
public ExercisesAdapter(Context context, SmoothCheckBox[] checkboxes) {
this.context = context;
this.checkboxes = checkboxes;
}
@Override
public int getCount() {
return checkboxes.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
gridView = new View(context);
// get layout from mobile.xml
gridView = inflater.inflate(R.layout.exercise, null);
TextView number = (TextView) gridView.findViewById(R.id.tv_exerciseName);
number.setText("No. " + position);
SmoothCheckBox checkBox = checkboxes[position];
return gridView;
}}
My layout for the checkboxes:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:app="http://ift.tt/GEGVYd"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_exerciseName"
android:layout_width="31dp"
android:layout_height="22dp"
android:textAlignment="center"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="2dp" />
<cn.refactor.library.SmoothCheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:checked="false"
app:layout_constraintTop_toBottomOf="@+id/tv_exerciseName"
tools:layout_editor_absoluteX="0dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="8dp" />
</android.support.constraint.ConstraintLayout>
Aucun commentaire:
Enregistrer un commentaire