2010-10-08 6 views

Répondre

0

Je ne sais pas beaucoup sur le Facebook, mais pour accéder à la composante ui de l'autre thread-

public class Dictionary extends Activity{  
    Handler mhandler; 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     Handler mhandler = new Handler(); 
     SearchThread thread = new SearchThread(); 
     thread.setParent(this); 
     thread.setHandler(mhandler); 
    } 
    public void notifyItemChanged(ArrayList<ListItem> lItems){ 
    //write code relating to ui here 
    } 
    private class SearchThread extends Thread{ 
     private Handler handler; 
     Dictionary parent; 

     public void setParent(Dictionary parent) { 
     this.parent = parent; 
     } 

     public void setHandler(Handler handler) { 
     this.handler = handler; 
     } 

     @Override 
     public void run() { 
      final Runnable mUpdateResults = new Runnable() { 
      public void run() { 
       parent.notifyItemChanged(listItems); 
      }     
     }; 
     handler.post(mUpdateResults); 
    } 
} 

Questions connexes