tob*_*ias 5 android view fragment
我正在使用此库在我的应用程序上使用表情符号键盘。 https://github.com/ankushsachdeva/emojicon
自述文件指出,必须使用活动布局层次结构的最顶层视图来初始化弹出窗口。
我的应用是通过片段实现的。
这是我用于测试的代码:
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;
}
Run Code Online (Sandbox Code Playgroud)
如果运行此代码,我将在logcat中收到以下错误:
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?
Run Code Online (Sandbox Code Playgroud)
编辑:我正在使用SherlockFragment
将视图保存为实例成员fragment并在方法中初始化表情符号弹出窗口OnViewCreated。这可能会解决你的问题。
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.overview1_layout, container,
false);
this.view = view
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// 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();
}
Run Code Online (Sandbox Code Playgroud)
但对于问题标题 - 请在此处查看
| 归档时间: |
|
| 查看次数: |
15517 次 |
| 最近记录: |