当主线程忙时,Contextmenu不工作?

时间:2017-05-14 06:16:28

标签: java android multithreading

我正在开发一个应用程序,我试图每隔一秒从另一个线程更新主线程。主线程中有一个列表视图,我每隔1秒修改一次列表的每个视图,并将结果发布到主线程。现在问题是主线程每1秒开始运行更改代码,这样就可以禁用长按操作。所以我不能使用上下文菜单列表视图的项目。所以如果你能帮助我,我会非常感激......

Runnable mStatusChecker = new Runnable() {
    @Override 
    public void run() {
          try {

                  for(int i=0;i<maxNumberOfDownloads;i++)
                {
                    if(i<ActiveDownload)
                    {
                        calculateDownloadDetails(i);
                    }
                }  

          } finally {
               // 100% guarantee that this always happens, even if
               // your update method throws an exception
               progressBarList.setAdapter(new DownloadingCustomAdapter(context,progressbarListDetails,ActiveDownload));
               mHandler.postDelayed(mStatusChecker, mInterval); 
               /*
                * The handler class is the only way to interact with the main UI, so when we want to update 
                * Something from the UI, we have to send the data to the main thread which is the MainActivity
                * postDelayed method adds the runnable mStatusChecker to the message queue every mInterval time
                */
          }
    }

0 个答案:

没有答案