0

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

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

4

1 回答 1

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(); 
            } 
            //});
        });

relaymain 是 .xml 文件的布局。

于 2012-04-26T20:54:13.957 回答