Reputation: 15166
I am using a custom GridPagerAdapter
and CardFragment
on the wearable. The CardFragment
has a TextView
that uses the android:ellipsize
attribute set to marquee
. The TextView
does not scroll until setSelected(true)
is called on it. The problem I am having is where to put that method call so that the text will only scroll when the card is in view. Right now I call the setSelected()
method in the onCreateContentView()
of the CardFragment
, but this makes it so that the text is always selected, and scrolls even when the card is not in view.
I have looked through the documentation for both GridPagerAdapter
and CardFragment
, but I do not see a method that would suit my needs. I have tried the CardFragment
methods onHiddenChanged()
, onStart()
/onStop()
and onResume()
/onPause()
. onHiddenChanged()
does not seem to get called at all. onPause()
and onStop()
seem to work as expected, but onStart()
and onResume()
get called before the fragment is actually in view. Is it possible to know when the card is actually in view (and when it is hidden), or am I out of luck?
Upvotes: 0
Views: 127
Reputation: 87430
In general, adapters just provide data, whereas the views that use them actually determine when to display it. Thus, I think you need to go directly to the GridViewPager
and add a GridViewPager.OnPageChangeListener
. That way you can listen for when the page is added and call setSelected()
then.
Upvotes: 1