For the record I managed to solve the scrolling problem.

The issue was setting an event listener to the onClick event on the
item view itself.

The correct method is use :setOnItemClickListener of the ListView
itself.
The same is correct for long press context menu. Registering for the
long press listener of the item view is wrong instead use:
ListView.setOnCreateContextMenuListener.

I couldn't find anything regarding this in the documentation so I
suggest this should be added.

G'day

On Feb 4, 5:46 pm, GDroid <[email protected]> wrote:
> Hi,
>
> I have a listview showing contacts.
>
> When I'm scrolling the list the scroll works pretty smooth however
> when/if I'm trying to continue the scroll in the middle of the last
> scrolling the scroll just stops and sometimes the item I clicked on is
> selected (I have registered an OnClickListener to the item view).
>
> I would like to get smooth scrolling just as in the device native
> contact list.
>
> My implementation builds each contact a view containing:
> 1. Big picture for the contact image.
> 2. Small picture for the type of the contact.
> 3. TextView with the Contact name
> 4. TextView with some extra text about that contact.
>
> My current layout for every item looks like:
> <LinearLayout >
>         <ImageView />
>         <LinearLayout/>
>                 <LinearLayout/>
>                         <ImageView />
>                         <TextView/>
>                 </LinearLayout>
>                 <TextView/>
>         </LinearLayout>
> </LinearLayout>
>
> I've tried changing the LinearLayouts to relative ones but saw no
> improvement in performance.
>
> I've created my own "Selector" in code (to eliminate the time it takes
> to load the resource) so that odd rows will have different background
> color. The code looks like:
>
> StateListDrawable draw = new StateListDrawable();
> draw.addState(new int[] {android.R.attr.state_selected},
> mSelectedRowDrawable);
> draw.addState(new int[] {-99},mOddRowBG);
> draw.addState(new int[] {},mRowBG);
> view.setBackgroundDrawable(draw);
>
> I'll be glad to give more details if needed.
>
> Thanks for the help.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to