4

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.

manjusg
  • 2,275
  • 1
  • 22
  • 31
  • hi check [this][1] post i think it's helpful to you [1]: http://stackoverflow.com/questions/1424276/ellipsize-not-working-for-textview-inside-custom-listview/1424686#1424686 – Pratik Jul 20 '11 at 09:01
  • thanks pratik, after looking into that thread. i tried this. android:ellipsize="marquee" android:scrollHorizontally="true",android:lines="1". but still no use. i am also not sure whether this will help me in enabling marquee only for the focused item. – manjusg Jul 20 '11 at 09:19

2 Answers2

2

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

duonghv
  • 346
  • 2
  • 4
  • i am using a convertview i.e the concept of lazy adapter. So when i put setselected on ontouchlistner for a single item . the marquee is appearing for others also.. – manjusg Jul 20 '11 at 10:36
  • I think you should not set marquee at getview() method.Only set when you touch on an item (get TextView from this item).If you can't do.Please contact with me.We will discuss more(skype,yahoo:fsoft_duonghv) – duonghv Jul 20 '11 at 10:39
  • thanks a lot duonghv. I am not setting marquee at getview(). I am setting it at ontouchlistner for KEY_DOWN action. and removing it on KEY_UP. I will try few things . if i get the result will let u know, else will surely contact u. – manjusg Jul 20 '11 at 11:01
  • And for clarification i am enabling the marquee by using setselected(true) and disabling it by setselected(false). – manjusg Jul 20 '11 at 11:11
  • Unfortunately not. whenever i do this always the top visible item of the list starts scrolling other than the focused listitem. I am not sure why this happens. I am setting the ontouchlisnter for the listview. – manjusg Jul 20 '11 at 11:30
0

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"
Larphoid
  • 1,005
  • 8
  • 13
  • Indeed there's a issue with textview .If its not in selected state it will not scroll. you just need to call textview.setselcted(true) and i don't see any need for calling requestfocusfromtouch to make marquee work. – manjusg Jul 06 '13 at 18:00