Marque effect for textual representation of a custom list item in touch focus

I created my own list view. Each list has a text view. I need to apply selection to it when users touch this particular list item.

I tried to install

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

This work, when I set setselected (true); in getview (), but for each list item. I need to include a selection area only for a focused / pressed element.

+4
source share
2 answers

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

+2
source

I know this is an old post, but recently I had this problem on my tablet that does not have a physical scroll button (like my phone) to scroll through the list items (without actually selecting the item by clicking on It). On my phone, when I look at the list items, the β€œbrand” has always worked from day one. So I played a little 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 tried all kinds of combinations of requestFocus, requestFocusFromTouch and list.setSelectionFromTop, but the above combination is the minimum of methods necessary for its operation, and so that the list remains in the position in which it is located. works with list.setSelection (position), but then the selected item will be deleted as far as possible at the top of the list, since this method is designed for this.

In xml, I got:

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

All Articles