Здравствуйте,подскажите как исправить данную проблему с переменной listitems массивов в классе Adapter и HorizontalAdapter .
Error:(140, 55) error: incompatible types: List<String> cannot be converted to List<ListItem>
public class Adapter extends RecyclerView.Adapter<Adapter.MemViewHolder>{
private List<String> listItems;
private List<String> list;
private Context context;
private List<String> uid;
private ProgressBar progressBar;
private RecyclerView recyclerView;
private TextView tv_likes, tv_dislikes, txtProgress;
private ImageView memImage;
private ImageButton button_like, button_dislike;
public Adapter(List<String> uid){
this.uid = uid;
}
@Override
public MemViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
return new MemViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.recycler_item, parent, false));
}
@Override
public void onBindViewHolder(MemViewHolder holder, int position){
FirebaseDatabase database;
DatabaseReference reference;
String uid = list.get(position);
database = FirebaseDatabase.getInstance();
reference = database.getReference("Memes").child(uid).child("url");
Log.i("DANIIL", uid);
reference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String url = dataSnapshot.getValue(String.class);
Glide.with(context).load(url).into(memImage);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
reference = database.getReference("Memes").child(uid).child("tags");
reference.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String tags = dataSnapshot.getValue(String.class);
char[] tags_c = tags.toCharArray();
String tag;
int i = 0;
while (tags_c[i] != '@'){
tag = "";
while (tags_c[i] != '%'){
tag += tags_c[i];
i++;
}
listItems.add(tag);
i++;
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
reference = database.getReference("Memes").child(uid).child("rate");
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String rate = dataSnapshot.getValue(String.class);
char[] rate_c = rate.toCharArray();
String likes_s = "", dislikes_s = "";
boolean flag = false;
for (int i = 0; i < rate_c.length; i++){
if (flag){
dislikes_s += rate_c[i];
}else{
if (rate_c[i] == '/'){
flag = true;
}else {
likes_s += rate_c[i];
}
}
}
tv_dislikes.setText(dislikes_s);
tv_likes.setText(likes_s);
Float likes = Float.valueOf(likes_s);
Float dislikes = Float.valueOf(dislikes_s);
Float ratingF = (likes / (likes + dislikes)) * 100;
Integer rating = Math.round(ratingF);
txtProgress.setText(rating.toString() + "%");
progressBar.setProgress(rating);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
listItems = new ArrayList<>();
recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL,false));
recyclerView.setAdapter(new HorizontalAdapter(listItems, context));//ошибка
public class HorizontalAdapter extends RecyclerView
.Adapter<HorizontalAdapter.HorizontalViewHolder> {
private Context context;
List<ListItem> listItems;
public HorizontalAdapter(List<ListItem> listItems, Context context) {
this.context = context;
this.listItems = listItems;
}
@Override
public HorizontalViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
View view = inflater.inflate(R.layout.tag_card, parent, false);
return new HorizontalAdapter.HorizontalViewHolder(view);
}
@Override
public void onBindViewHolder(HorizontalAdapter.HorizontalViewHolder holder, int position) {
ListItem listItem = listItems.get(position);
holder.tagText.setText(listItem.getTag());
}
public class ListItem {
private String tag;
public ListItem(String tag){
this.tag = tag;
}
public String getTag(){
return tag;
}