自述说明你的Activity 布局层次结构的最顶端视图必须用于初始化 popupwindow 。
我的应用是通过 Fragments 实现的。
这是我用于测试的代码:public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.overview1_layout, container,
false);
//Give the topmost view of your activity layout hierarchy. This will be used to measure soft keyboard height
EmojiconsPopup popup = new EmojiconsPopup(view, getActivity());
//Will automatically set size according to the soft keyboard size
popup.setSizeForSoftKeyboard();
popup.showAtBottom();
return view;
}
如果运行这里代码,我将在printserver中遇到以下错误:11-02 22:37:16.685: E/AndroidRuntime(30363): java.lang.RuntimeException: Unable to resume activity {com.Testing.full/com.Testing.full.MainActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
编辑:我正在使用 SherlockFragment