2012-04-24 80 views
0

的醫生說我應該增加這樣的事情我的代碼:添加LeadBolt應用內廣告 - 如何添加一個Runnable

// create a new layout 
LinearLayout layout = new LinearLayout(this); 
/* 
Add any elements to your view 
*/ 
// make the view visible 
this.setContentView(layout); 
final Activity act = this; 

// now add the banner or overlay to the app 

layout.post(new Runnable() { //what about this line? 
public void run() { 
myController = new AdController(act, MY_LB_SECTION_ID); 
myController.loadAd(); 
} 
}); 

我的佈局是在XML中,我已經定義setContentView(R.layout.config);我指的是layout.post(new Runnable() { line。我應該如何修改代碼?

+0

沒有人?我不這和LeadBolt有什麼關係,問題是如何設置runnable? – erdomester 2012-04-25 08:24:18

回答

0

對於任何人誰是有興趣的,我發現了明顯的解決方案:

RelativeLayout rellaymain = (RelativeLayout)findViewById(R.id.rellaymain); 

     final Activity act = this; 
     rellaymain.post(new Runnable() { 

      public void run() { 
      myController = new AdController(act, MY_LB_SECTION_ID2); 
      myController.setAsynchTask(true); 
      myController.loadAd(); 
      } 
      //}); 
     }); 

rellaymain是.xml文件的佈局。