Android - How to tell when a specific view has been rendered?

前端 未结 2 1315
萌比男神i
萌比男神i 2020-12-12 01:34

I have a regular button that I want to display a timer on. So imagine the text of the button changes every second as a countdown timer. However, I need this timer to only st

2条回答
  •  死守一世寂寞
    2020-12-12 02:10

    You could create a custom button then implement onFinishInflate() or when you initialize the custom button, set it's visibility to invisible and implement onWindowVisibilityChanged(int). Then when you set the button to visible you start the timer. You could also have it be a start button, which when pressed starts the timer and changes what's needed to behave as a timer button.

    http://developer.android.com/reference/android/view/View.html

提交回复
热议问题