添加LeadBolt App广告 - 如何添加Runnable

时间:2012-04-24 18:33:14

标签: android leadbolt

文档说我应该在我的代码中添加这样的内容:

// 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。我该如何修改代码?

1 个答案:

答案 0 :(得分: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文件的布局。