0

I use a checkable listview ( I've set : Mylistview.setChoiceMode(1)).

Inside each row I have 2 ImageViews and 2 TextViews.

I'd like that when my item is checked, the text inside the TextViews scrolls if the text is too long. So in the XML of my row, I've assign the following to both of my TextViews :

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

Unfortunately, this will make the text scroll only if the item is focused and not checked.

So the solution I think about are :

1) Make my own Custom TextView class and make it focus itself when checked (I don't know if it is possible ?)

2) Put the focus to the checked item even if we're in touch mode (use SetFocusableInTouchMode)

I haven't achieved to do the 2nd solution and I don't know which method override if I want to make my own own Custom TextView.

Could you help me to make the text scroll when the item is checked ? Thanks.

Jecimi
  • 4,113
  • 7
  • 31
  • 40

1 Answers1

0

You need to do something like following.

int scrollAmount = mTextView.getLayout().getLineTop(mTextView.getLineCount())
        -mTextView.getHeight();

// if there is no need to scroll, scrollAmount will be <=0
if(scrollAmount>0)
    mTextView.scrollTo(0, scrollAmount);
else
    mTextView.scrollTo(0,0);
Vipul
  • 27,808
  • 7
  • 60
  • 75
  • Well, I'm not talking about the vertical scroll but about the very specific horizontal scroll animation that the `android:ellipsize="marquee"` procure. I found this [post](http://stackoverflow.com/questions/1827751/is-there-a-way-to-make-ellipsize-marquee-always-scroll) which shows how to make the text always scroll with a custom TextView. But I'm not able to adapt it to make it scroll when the item's checked only. – Jecimi Jun 12 '12 at 15:36