0

I got this error trying to get all items with specific object and store it to my Listview.

Following the codes:

   SimpleDateFormat formatdate = new SimpleDateFormat("MMM. dd, yyyy");
            String selecdate = formatdate.format(date);

            if (eventDates.contains(selecdate)) {
                for (int i = 0; i < eventsList.size(); i++) {
                    HashMap<String, Object> obj = (HashMap<String, Object>) adapter.getItem(i);
                    ListAdapter list = (ListAdapter) obj.get("eventtitle");
                    myList.setAdapter(list);
                }
            }
            else {
                myList.setAdapter(null);

            }

1 Answer 1

1

java.lang.String cannot be cast to android.widget.ListAdapter

This line is saying that your obj.get("eventtitle"); is returning String as a value not a ListAdapter

As docs says

public abstract Object getItem (int position)

Get the data item associated with the specified position in the data set.

So might be your dataSet is of String rather than ListAdapter

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.