How to avoid Tap to Refresh - android

I am using:
https://github.com/johannilsson/android-pulltorefresh
To get pull to refresh.
The problem is when I open the ListView for the 1st time, it shows a top header saying:
Tap to Refresh
When I do that it shows
Loading
and gets hidden. Then after everything works fine.
How to avoid showing that initial Tap to Refresh header and just show my ListView with Pull functionality alone

Issue here is when ListView don't have sufficient items to scroll it shows TAP TO REFRESH text when ListView has sufficient items that text gets hide so your issue is your list don't have many items at first time...

Related

Android Accessibility issues

I have couple of issues in the process of making my app accessibility compliant.
I have a spinner with some items in it, after I select one of the item, spinner closes and focus is moving to the top of the page action bar but I want the focus to remain on the last used element i.e, the spinner. Tried:
spinnerId.requestfocus(); or spinnerId.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS,null); in the code but nothing worked.
2.How can I set the focus to last accessed element even if onResume(); is called to refresh the data ?
3.Page reverse order doesn't work all the time when I scroll back through the elements.
4.I have a listview with elements populated dynamically, accessibility doesn't scroll the page all the times instead it goes to right fragment( i have left and right fragments in my tablet) skipping the elements below the screen.
As your spinner is already focus, you have to clear this focus, send this event to Accessibility and request it again:
yourView.clearFocus();
yourView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
yourView.requestFocus();
yourView.setFocusableInTouchMode(true);
He took me awhile to find this tricks, but we used it in few different place in our app, and it work well.

Get RecyclerView to stop scrolling when I add items to the Adapter

How can I stop RecyclerView from scrolling to the bottom of the list whenever I add items?
Even when I insert something at the top of the list and call notifyDataSetChanged or notifyItemInserted the list scrolls to the bottom.
The one feature that works as expected is notifyItemRemoved(index)
I think I was calling notifyRangeInserted() with the entire list and that was scrolling to the end of that range.
If you're having similar issues, just cut the Adapter functionality back to its bare essentials and build up from there.
The problem was I had an item in the list, a ProgressBar to indicate that data was loading, but when the new items loaded I added them to the list, this moved the "focused item," the ProgressBar down and if there were enough items to move it off the screen then the RecyclerView would scroll down to keep it on screen. The problem being 1. I didn't want it to maintain "focus" and 2. The very next thing I did was remove the ProgressBar from the `Adapter.
So the solution is to remove the ProgressBar or other items before adding items earlier positions in the Adapter.

Load list items on demand

I would like to load a list of messages on demand.
I show 20 messages on my listview and when the user scrolls on top of list there is a button to load more 20 messages.
Like whatsapp, when user clicks on the button, more messages are loaded above and the user can scroll 20 more messages.
I have tried to make it with Loaders, every time the button is clicked I publish an event that load messages on the adapter.
However when the adapter is releoaded with new itens the focus goes to end of list.
I have tried to set the focus to the right positon, but the Loader's events reload the adapter and the focus come back to end of list.
The only solution I found was to set the focus after a time, but the user can see the list going to end and coming back to the right postion.
How can I load messages on demand like Whats app?
You have to add only 20 objects in your ArrayList and add HeaderView in your list adapter .On click on headerView .It will load more 20 items in your list adapter . and call notifyDataSetChange(); afterwards.

Android Listview jumps on change in adapter content

I am using a scroll listener to detect the end of the Listview.The list initially has 20 items. When the end is reached I populate the list with 10 more items from the DB. At the same time I remove the top 10 items which aren't visible. Since I delete the top 10 items the newly added items are shown on screen and the scroll listener detects end of list and populates 10 more items. So my two problems are
1) How do I stop the position of the item I am currently viewing from changing ?
2) How to prevent the onScrollListener from being called multiple times ?
I guess if you could help me with the first problem, the second would automatically be taken care of.
By the way ,I call notifyDatasetchanged to update the content of the adapter. Kindly help, and thanks.

Unable to update the listView in Android

I have a ListView which displays 5 listitems. When the user selects the last item (5th item), a hit goes to server and the next set of 5 items is displayed.
I have implemented the code for displaying the first 5 items. I am also able to fetch the next set of items from the server, but the items are not updated in the ListView.
If required I can share the sample code.
Kindly provide hints/sample source code.
Did you try clearing the list items first and then update the list elements?
In order to commit the updates you should call notifyDataSetChanged() ..

Categories

Resources