You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm trying to use the ChipsInputLayout in my project and I'm struggling with it. The problem is that the widgets doesn't show any options, although I have set a proper filterable list. It doesn't even show any chips that I add manually. I suppose it's not really a bug, but probably I'm doing something wrong. Anyway, I'd be thankful if the author of the library can have a look at it.
I inherited the Chip class like this:
public class ContactChip extends Chip {
private String name;
private String number;
public ContactChip(@NonNull String name, @NonNull String number) {
this.name = name;
this.number = number;
}
@Override
public Object getId() {
return number;
}
@NonNull
@Override
public String getTitle() {
return name;
}
@Override
public String getSubtitle() {
return number;
}
@Override
public Uri getAvatarUri() {
return null;
}
@Override
public Drawable getAvatarDrawable() {
return MyApplication.getInstance().getDrawable(R.drawable.ic_people_black_24dp);//todo replace
}
}
Then I added the widgets to my fragment's xml like this:
(Note that the chipsList attribute is just a custom attribute for Android Data Binding, but I already tried to delete it, the widget didn't work either.)
And then I have this method, which is called in onCreateView() of the fragment's class:
private void initChipsInput(@NonNull final ChipsInputLayout chipsInput) {
ArrayList<Message.Recipient> contacts = ContactsDataSource.getInstance().getContacts();
ArrayList<Chip> chips = new ArrayList<>();
for (int i = 0; i < contacts.size(); i++) {
Message.Recipient contact = contacts.get(i);
chips.add(new ContactChip(contact.name, contact.number));
}
chipsInput.setFilterableChipList(chips);
chipsInput.addSelectionObserver(new ChipDataSource.SelectionObserver() {
@Override
public void onChipSelected(Chip chip) { updateVM(); }
@Override
public void onChipDeselected(Chip chip) { updateVM(); }
void updateVM() {
if(viewModel != null) {
viewModel.chips.clear();
viewModel.chips.addAll(chipsInput.getSelectedChips());
}
}
});
}
Again, it didn't work even when I deleted the selectionObserver. The mechanism of getting the list of contacts is working correctly, I tried to run it in the debugger and the list passed to setFilterableChipsList() is OK, it contains 64 items with all the names and phone numbers of my contacts. And still it doesn't show any list of options when I type anything. I also tried to manually add some chips by calling addSelectedChip(), and it wasn't shown. It's just behaving like a normal EditText... Thanks for any help.
The text was updated successfully, but these errors were encountered:
UPDATE: I did some debugging and found out that FilterableRecyclerView.fadeIn() is called when it should be and it's actually setting itself to visible. I have even checked the LayoutParams it creates in that method, and the top and bottom margins are OK. But I also found out that FilterableChipsAdapter.onCreateViewHolder() is never called. It's weird, but now I believe that this is a bug, not my fault. I can send you my whole project to look at it.
Hello,
I'm trying to use the ChipsInputLayout in my project and I'm struggling with it. The problem is that the widgets doesn't show any options, although I have set a proper filterable list. It doesn't even show any chips that I add manually. I suppose it's not really a bug, but probably I'm doing something wrong. Anyway, I'd be thankful if the author of the library can have a look at it.
I inherited the Chip class like this:
Then I added the widgets to my fragment's xml like this:
(Note that the chipsList attribute is just a custom attribute for Android Data Binding, but I already tried to delete it, the widget didn't work either.)
And then I have this method, which is called in onCreateView() of the fragment's class:
Again, it didn't work even when I deleted the selectionObserver. The mechanism of getting the list of contacts is working correctly, I tried to run it in the debugger and the list passed to setFilterableChipsList() is OK, it contains 64 items with all the names and phone numbers of my contacts. And still it doesn't show any list of options when I type anything. I also tried to manually add some chips by calling addSelectedChip(), and it wasn't shown. It's just behaving like a normal EditText... Thanks for any help.
The text was updated successfully, but these errors were encountered: