为什么在活动开始时滚动视图只能在可运行的情况下工作?
为什么
HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.buttons);
if (null != hsv) hsv.scrollBy(iLengthToScroll, 0);
onResume 中的操作不执行任何操作,而是
Handler mHandler = new Handler();
Runnable scroll = new Runnable()
{
@Override
public void run()
{
HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.buttons);
if (null != hsv) hsv.scrollBy(iLengthToScroll, 0);
}
};
mHandler.post(scroll);
进行滚动? Handler.post 将 runnable 添加到 UI 线程中,但 onResume 已经在 UI 线程中了,不是吗?
Why does doing
HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.buttons);
if (null != hsv) hsv.scrollBy(iLengthToScroll, 0);
in onResume do nothing, but
Handler mHandler = new Handler();
Runnable scroll = new Runnable()
{
@Override
public void run()
{
HorizontalScrollView hsv = (HorizontalScrollView) findViewById(R.id.buttons);
if (null != hsv) hsv.scrollBy(iLengthToScroll, 0);
}
};
mHandler.post(scroll);
do the scrolling? Handler.post adds the runnable to the UI thread, but onResume is already in the UI thread, isn't it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论