Unable to display data on listview - android

I am having an issue with displaying the data on my list view that been extracted from Firebase Database. There are my codes:
I hope if any of you could help me debug this error!
Thanks lads.

As explained in this post, to update an ArrayAdapter, you need to call the notifyDataSetChanged() method after changing the contents of the ArrayList.

Related

Update recyclerview from the adapter

I am trying to update data in the recyclerview from the adapter, a function inside the adapter to do the update.
It is working properly and data is being added to the database but it is not updating the views, I need to restart the app so that it runs the cursor to get data from the database and load the views.
I figured out that the main problem is the different lists in the adapter and in the main activity. The list from the main activity is controlling the views so that when i update the list in the adapter nothing happens.
'''kotlin
private val adapter = Padapter (mainActivityList)
and
class adapter(private val adapterList:ArrayList)
'''
How can I do it ? Should i try to call a function in the main activity ?
I really appreciate any help or suggestions you can provide.
I solved it as adam yong suggested in the comments. I stored the list in the adapter.
At first i didnt know how to do that but i discovered somewhere that i had to call the list to the database thought the adapter like this :
In the main activity:
"'Kotlin
adapter.list.addAll( dbHandler!!.cursor())
"'

Android Sqlite and notifyChanged()

Can anyone help me in populating the values from database and show in listview using the notifychanged()
you do not need to refresh activity. after fetching data from database you update your ArrayList or something like that, and call notifiyDataSetChanged() and it is done.

Couldn't clear an ArrayAdapter

I have a GridView backed by an ArrayAdapter. Everything works except for one thing: I couldn't clear that adapter (need this when refreshing the `GridView).
This is what I have:
adapter.clear();
adapter.notifyDataSetChanged();
Prior to this project I have never had any issue regarding adapter clearing. I can't find what I am doing wrong here.
Any idea? (don't hesitate to ask for specific details).
Thanks!
Problem solved.
I had to keep a reference on the collection that the adapter was taking its data from and then do:
myCollection.clean();
adapter.notifyDataSetChanged();

android listview refresh

hello every one
i want to refresh my listview after adding or removing any data.. the adapter is from the SDcard how can i do this?
thanks in advance
call this code after your data are
change..
adapter.notifyDataSetChanged();
Use notifyDataSetChanged() of ArrayAdapter.
See the following code:
((EfficientAdapter)listView1.getAdapter()).notifyDataSetChanged();
Hope this will help you.

android - ListAdapter deleting item - refreshing view

I'm trying to delete items from a ListView using a custom adapter which extends SimpleCursorAdapter.
When I try to delete one of the list items, I want to the ListView to refresh itself. I have read from other posts, that you can do this by calling Cursor.requery().
While the database is consistent, that is, the deletion takes place, Cursor.requery() returns true, but instead of showing me the updated list, it shows me an empty list with the empty TextView I have set in my xml file with this id android:id="#id/android:empty"
Any ideas?
Thanks
You have other code in there beyond the requery() call that is messing things up. Here is a sample project demonstrating the use of requery() to update a ListView when a new item is inserted or deleted.
Ok I've found my own problem.
I was closing the database.
Perhaps I only need to close the database when the activity is paused/stopped etc..

Categories

Resources