Closed ghutchins56 closed 2 years ago
@ghutchins56 could you please share some code examples here. It's usually more open to collaborate more openly, so other people can also chime in and help.
I appreciate your prompt reply and suggestion. I made ghutchins56/GilCash public. I apologize for having made it private.
public class MainActivity extends AppCompatActivity {
. . .
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
itemAdapter = new ItemAdapter<>();
FastAdapter
public class SimpleItem extends AbstractItem
public SimpleItem(String date) {
this.date = date;
}
@Override
public int getType() {
return R.id.simple_item;
}
@Override
public int getLayoutRes() {
return R.layout.simple_item;
}
@NonNull
@Override
public ViewHolder getViewHolder(@NonNull View view) {
return new ViewHolder(view);
}
protected static class ViewHolder extends FastAdapter.ViewHolder<SimpleItem> {
TextView date;
public ViewHolder(@NonNull View itemView) {
super(itemView);
date = itemView.findViewById(R.id.date);
}
@Override
public void bindView(@NonNull SimpleItem item, @NonNull List<?> list) {
date.setText(item.date);
}
@Override
public void unbindView(@NonNull SimpleItem item) {
date.setText(null);
}
}
}
I'll need to take a closer look at this. on the first look at the code I don't see anything immediately wrong.
Have you had the chance to build and try out the sample application? Which includes a lot of different ways to use the library.
One thing I see which may cause problems (unrelated to this library though).
Your RecyclerView
is wrap_content
so it may be wrongly sized: https://github.com/ghutchins56/GilCash/blob/master/app/src/main/res/layout/activity_main.xml#L12
You may wanna use match_parent
instead. or align it fully in the layout
app:layout_constraintBottom_toTopOf="@id/add_item"
Don't forget to alignt he button also to the bottom:
<ImageButton
android:id="@+id/add_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:contentDescription="@string/add_item"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/item_list"
app:layout_constraintBottom_toBottomOf="@id/add_item"
app:srcCompat="@drawable/icon_add" />
I appreciate the suggestions and will try them. I installed the sample app from the Play Store and used the simple item example without any problems. I'll try building the sample app project.
Your suggestion about the RecyclerView and wrap_content got me on the right track. I also changed the height of simple_item from match_parent to wrap_content. This last change fixed the rest of the problem. As you said, this was not a problem with the FastAdapter library.
About this issue
Details
Checklist