How to stop scrolling listview above first Item? - android

My Query is in my ListView let say if I scroll to 1st position that is fine but now my ListView scrolls beyond that also like my fisrt item will also go down and there is no item before first item so blank screen comes which is looking very bad i hope, i have described well can anybody look into this.

I have seen this issue in Galaxy S while over other devices this behaviour is not followed. So I think some device manufacturers have modified their OS and we can't do anything in this case.

Related

Android RecyclerView items empty when being swiped after switching apps

First of all, I have looked at similar questions (for example, this one: Android RecyclerView ItemTouchHelper revert swipe and restore view holder). This already helped a great deal, until I - more or less, accidentally - noticed my current (and hopefully, final) issue with this screen of mine.
Let's start with the setup:
I have a fragment with a RecyclerView filled with some CardView items (it's a little fancier, but that's what is important right now). I also created an ItemTouchHelper with the implementation of SimpleCallback (nothing in onMove()) to make swiping the items (right) possible. For the record: I am using API 27 right now.
So far, so good.
What I want to achieve:
I want to be able to swipe the items to be notified through the onSwiped() method of my SimpleCallback implementation. Also, I do NOT want the items to disappear, be removed, or otherwise taken out of my list of items in the RecyclerView. I just want to swipe them and have them return to their original position afterward (and yes, I know that it is sort of assumed that swiped items get removed). I am using the notifyItemChanged() method of my adapter in the onSwiped() method (also tried using notifyDataSetChanged()).
The problem:
Funnily enough, that works (mostly thanks to the aforementioned question) - until I hit that "app switch" button (don't know if there's actually one official name for it) and send the app to the background. Once I put it in the foreground again and start swiping, the items will not (visually) return. They are still on the list, and if I scroll or click the "app switch" button again, they will be displayed properly again (but won't return on swiping). Same if I navigate back one screen and come back to the list.
That makes me think something happens when I send the app to the background and recover it. Something different than navigating to that screen (in which case everything works as intended) - which I thought would more or less produce the same results. Any ideas what I might be overlooking here?
After some testing, I finally found the source of the issue:
I had both the RecyclerView and its Adapter initialised through onStart() of the Fragment and not onViewCreated(). After changing that, I got the proper results I wanted.
Lesson learned: Set your RecyclerView's Adapter as early as possible, unless you want to deal with sometimes strange issues.

How to create horizontal listview which is fix the count of item when display

I want to create a horizontal listview which contain many item, one item will contain a image. When user slide listview => the count of item will be fix when it display, example display only 3 or 4 image. How can I do that? Many thanks.
Edit:
I use this
to create a HorizontalList view, everything is ok but I don;t know how to make the Next and Previous button work! Any idea?
Instead of a horizontal ListView (which, as far as I know, isn't offered by the Android SDK) you can use a HorizontalScrollView. You can add the items like to any other kind of layout class.
It looks like what you are looking for is a Paginated Gallery. I have written one here.
Its still only a couple of days old but hopefully the included Activity code will get you off the ground.

Android load listviews at end of scrolling

I want to implement functionality where a listview loads a set number of views, but at the end of the scrolling it has a spinner in that view, while it loads more views
the official android twitter app has something like this, where it shows you old messages from your timeline but at the bottom of the list it will load more after running a spinner. you can still scroll up and down while this thread is happening without breaking anything
how would this be done? insight appreciated
i think by spinner u mean blocking screen ?
anyways what u need is pretty common, just search for listview implementation in android
here is one of the link i still had:
http://blog.zjor.ru/2010/12/loading-list-data-asynchronously-in.html
also check this if u really want to go to that extent ;)
https://github.com/commonsguy/cwac-endless
basically, it would probably be something like:
Load some data (use a limit)
When you enter the bindView of your last element, change your limit (may be by joining the cursor to another one)

Android GridView Issue

In GridView the item at index 1 is not receiving click event but all other items are receiving click event in Galaxy S and in HTC Hero all items are receiving click event.What is this? Please explain.......thanks for giving time.
You shouldnt have any issues with this. i have used it tons of times. be sure to check the code you are using. Try to log the position in onItemClick see what it returns. also click don't work if you are using buttons or other similar controls inside the list rows. that requires a different aproach.

Refresh Android listview after scrollBy on

This is my first post on stackoverflow. I use this one some times when I have a problem and find a solution every time. But today is different. Have a non-solved problem :
I have on listview and I want apply a magnetic effect on this. To make this, I use scrollBy one by one pixel with Thread to move listview position. Visually, it's perfect, listview move good. But when user want scroll again, listview come back to his previous position (just before scrollBy) before scroll normally with user finger.
I've tried some tests, for exemple I display v.getTop() (v is on view item in listview) value BEFORE my scrollBy and AFTER. Values are same, but visually are really different because list are moved. Also visually, you can see a little artefact : this divider is ON listview item. It's means that visually, listview is good, but programatically isn't good... while scrollBy make invalidate estate.
Anyone have an idea or a solution ?
Thnak you for your help.
PS : Sorry for my english, i'm french. Thank you again.
Use getScrollY() to find the current position and then set that position after it gets reset.

Categories

Resources