[英]Android. How to make view clickable when mediaplayer stops playback
我具有創建視圖和媒體播放器的Acvtivity。 我想使用OnCompletion事件使該視圖可單擊。 但這引發了異常,我不知道為什么。 媒體播放器可能在另一個線程中運行,並且無法從主ui線程訪問元素嗎? 謝謝你的任何信息
使用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
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.