Button r=new Button(this); 就出错,不知道什么原因?该怎么处理

Button r=new Button(this); 就出错,不知道什么原因?
@Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
 
 
   
  //TableLayout MainT =(TableLayout) this.findViewById(R.id.MainT);
  Button r=new Button(this);
 
  // LoadMainT(MainT,this);
  this.setContentView(R.layout.main);
   
  }

------解决方案--------------------
探讨

// LoadMainT(MainT,this);
this.setContentView(R.layout.main);
Button r=new Button(this);

颠倒一下顺序应该就没事了