0
我有创建视图和媒体播放器的活动。我想使用OnCompletion事件来使该视图可点击。但它抛出异常,我不知道为什么。可能mediaplayer在另一个线程中运行,无法访问主UI线程中的元素? 感谢您的任何信息Android。当mediaplayer停止播放时如何使视图可点击
我有创建视图和媒体播放器的活动。我想使用OnCompletion事件来使该视图可点击。但它抛出异常,我不知道为什么。可能mediaplayer在另一个线程中运行,无法访问主UI线程中的元素? 感谢您的任何信息Android。当mediaplayer停止播放时如何使视图可点击
使用Activity.runOnUiThread()
确保您的代码运行在正确的线程中。
//assuming this code is within an Activity class, you can
//access this function directly. Otherwise you must
//have a reference to an Activity object
this.runOnUiThread(new Runnable()
{
public void run()
{
//perform UI-thread only tasks
}
});