addView报空指针,该怎么处理

addView报空指针
想实现的功能是,点击一个按钮,出来一个list,上面有几个按钮。但是addView时候出现空指针。代码如下:
MainActivity类:
package com.example.tablelayout;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

findViewById(R.id.button1).setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
PlatformPage page = new PlatformPage(v.getContext());
page.show();
}
});
}
}
PlatformPage 类:
package com.example.tablelayout;

import android.content.Context;
import android.widget.TableLayout;

public class PlatformPage extends TableLayout {

public PlatformPage(Context context) {
super(context);
}

public void show() {
TableLayout tableLayout = (TableLayout) findViewById(R.id.platformLayout);
this.addView(tableLayout);
}
}
请前辈指导
------解决方案--------------------
楼主debug一下tableLayout是不是null
------解决方案--------------------
在监听器中实现findViewById,应该会出问题,最好在oncreate中建立好tableLayout,点击的时候显示就好了
------解决方案--------------------
这样写是有问题的、  你在点击事件里 调用show方法, 就相当于把show里面的代码放过来 就会出现问题了、放过来一看你就知道有问题了、
------解决方案--------------------
        LayoutInflater inflater = LayoutInflater.from(this);
        inflater.inflate(R.id.platformLayout, null);
this.addView(tableLayout);