manjusg
manjusg

Reputation: 2263

marque effect for text view item of custom listview on touch focus

I have created a custom list view . In each listitem i have a textview. I need to apply marquee for it whenever users touches that particular list item.

i had tried setting

android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"

This work when i putted setselected(true); in getview(), but for every item of the list. I need to enable the marquee only for the focused/pressed item.

Upvotes: 4

Views: 2034

Answers (2)

Larphoid
Larphoid

Reputation: 1005

I know this is an old post, but recently i had this issue on my tablet, which doesn't have a physical scroll button (like my phone has) to scroll over listview items (without actually selecting an item by clicking on it). On my phone, when i scroll over the listview items, the "marque" has always worked from day 1. So i did some fiddling in onListItemClick...

This is the result:

@Override
protected void onListItemClick(ListView list, View v, int position, long id) {
    final View t = v.findViewById(R.id.YOURTEXTVIEW_ID_HERE);
    t.requestFocusFromTouch();
    list.setSelectionFromTop(position, v.getTop());
    super.onListItemClick(list, v, position, id);
}

I've tried all kinds of combinations of requestFocus, requestFocusFromTouch, and list.setSelectionFromTop, but the above combination is the minimum of methods that is required to make it work and have the listitem stay at the position it's in. It also works with list.setSelection(position) but then the selected item will be shoved to the top of the listview as much as possible, as this method is intended to do.

In xml i only got:

android:ellipsize="marquee"
android:singleLine="true"

Upvotes: 0

duonghv
duonghv

Reputation: 346

I think when you touch on an item, at this time, you get TextView after that set marquee for it.Goodluck.

Upvotes: 2

Related Questions