Android: Moving window of items in a ListView? - android

I am trying to update the ListView with periodic updates taken from an HTTP response. Now, I am thinking that because this is very specific to my application, I can get away by using a background thread and then updating the ListView using the magic UI thread. The last time I tried this, I had to remove the entire adapter of the ListView and then fill it up again so it worked. But this time, what I am trying to do is a more "smooth" scrolling ListView... something like a scrolling ticker... Is there a different approach to achieve this?

That depends on the Adapter. If you are using an ArrayAdapter, you can call add() on the ArrayAdapter itself to add items on the fly.

Related

How to create a Listview which refreshes along with scrolling in android?

I want to create a ListView which gets information from a database using VOLLEY. I want to call the Volley in a loop which will allow the data to come one by one. Is there any way to make a ListView which adds items whenever volley gets a item returned from the database?
You can use some libraries way cooler to top your ListView from android-arsenal.com . here is a list of libraries that are even new https://android-arsenal.com/tag/78?sort=created
You can see a detailed video by Vivz from Slidenerd Pull to refresh tutorial
Add items to your item set, and simply notify the adapter (adapter.notifyDataSetChanged();) that items been changed.
If you going to insert them one by one you might want to look into RecyclerView and use its notify methods like notifyItemInserted. It is specially designed for that and comes with animations to represents an item being inserted/updated/moved/deleted.

How to refresh data in adapter without calling notifyDataSetChanged

I'm using recycler view with grid view (every item contains a grid) with thumbnail images after adding images in view it start uploading, and i need to change some values (status) in model at the time of start and finish upload.
What I'm currently doing is change values in model and call notifyDataSetChanged, but it causes to slow down application (hang some times) because it updating every child of list :(
Can any one help me with this?
Call notifydatasetchanged() for particular Gridview adapter only. Don't call notifydatasetchanged() for complete recyclerview adapter.
Try setting it again to the adapter.
gridview.setAdapter(your adapter)
-passing your new list to your adapter.
I believe notifyDataSetChanged updates all of your values regardless if they have a change or not that is why it is slow. I suggest you try using notifyItemChanged(int position) instead.
According to recyclerview docs this is what notifyDataSetChanged does:
This event does not specify what about the data set has changed, forcing any observers to assume that all existing items and structure may no longer be valid. LayoutManagers will be forced to fully rebind and relayout all visible views.
Old question but similar to what I'm experiencing.
RecyclerView is usually incredibly fast when changing list details. But manipulating a lot of images can really slow it down if you're not careul.
I'd recommend you try removing the images and repeat it so you can see if that is just as slow. I suspect this will be a lot faster.
If so, make sure you're handling the images off the UI thread. The Android docs recommend you use a library such as Glide which also handles sub-sampling the image to make sure it's the right size.
Hope that helps!

How to refresh Expandable Listview's groupview

I want to achieve a function of when I click the group the activity will do something background and when it has finished ,I want the groupview has something different.So I want to know how to fresh the groupview.
Well you better post some code to get the right advice on your issue but based on the text inside your question I can suggest these steps,
setOnGroupExpandListener(new OnGroupExpandListener(){..}); on your expandable listview.
You will get onGroupExpand method where you will write your logic to refresh or do whatever you need to do in background in an Asynctask obviously.
Once you are done with the background work then inside onPostExecute() of your Asynctask set the adapter again or just call notifydatasetchanged if you have modified the data a bit.

Listview fillup with adatper

I have created custom listview with baseadapter.
it's working fine.
but I am calculating total amout when adatper is filliup via getview method.
My question is when I can find that adapter has completed his process of filling up listview?
When adapter called getview() method for last the record after that I want to broadcast message. How can I do?
Thanks.
Adapter does not fill listview completely. It will only fill views that are on the screen ( it also depends on framework cos companies like Samsung, Sony do change the android framework a lot)
The best you should do is call Notifydatasetchanged on adapter and then handle call after that.
Views and whatever adapter needs to call should be done by then
Can you please explain more what you want to achieve. You probably need to use the adapter data and not think about touching its UI part?

displaying item on specific listview item only

I am trying to get a button to show up on my list item (declared as android:visibility:"gone" in the XML) to show as visible when I perform some gestures on it. However, how can I actually notify the getView method correctly to display the button only on the listview item?
I tried using getChildAt(position) which ended up displaying several buttons at once.
I tried passing in the position for example I detected that the gesture was performed on from pointToPosition and passed it into the adapter for the getView method to display, but it had the same problem of displaying several at once.
do anyone know how can I solve this?
I think you may have a misunderstanding of how Adapter.getView() works its meant to create or reuse layouts when rendering the ListView it also needs to be fast so conditional manipulation in this method is discouraged. Although ListView.getChildAt() may work it does not effectively use the API. Your adapter will have a setViewBinder() unless you're using an ArrayAdapter (if so I suggest using SimpleAdapter because of the additional features). Use your ViewBinder implementation to switch the visibility of the button.
If you'd prefer to continue to use ArrayAdapter use ListView.getChildAt(int) to findViewById(R.id.your_button).setVisibility(). If this is what you already tried and its setting all the buttons visible then please post the related code.

Categories

Resources