Android Fragment 之运行PopupWindow提示 token null is not valid; is your activity running?
由于控件未初始化完成,会导致失败,需要在生命周期方法完成后调用。
建议找一个控件,调用 post方法,进行条用。(post方法可以延迟在所有生命周期完成后执行)
bt = (Button)findViewById(R.id.button);
bt.post(new Runnable(){
@Override
public void run() {
//构建PopupWindow
openPop();
}
});