所以我正在制作一款使用三星Pen SDK的应用程序,唯一的问题是他们的例子,ComposerSample7_1_Composer,还有用于创建上下文菜单的代码,
private void createContextMenu(Menu menu) {
final boolean editable = mSpenComposerView.getMode() == SpenComposerView.MODE_EDIT;
final SpenSDoc.CursorInfo begin = mSDoc.getSelectedRegionBegin();
final SpenSDoc.CursorInfo end = mSDoc.getSelectedRegionEnd();
Log.d(TAG, "SpenContextMenuListener$createContextMenu : " + begin.index + " - " + end.index);
menu.add(Menu.NONE, CONTEXT_MENU_ID_CUT, CONTEXT_MENU_ID_CUT, "CUT")
.setEnabled(editable);
menu.add(Menu.NONE, CONTEXT_MENU_ID_COPY, CONTEXT_MENU_ID_COPY, "COPY")
.setEnabled(mSDoc.isSelected());
menu.add(Menu.NONE, CONTEXT_MENU_ID_PASTE, CONTEXT_MENU_ID_PASTE, "PASTE")
.setEnabled(editable);
menu.add(Menu.NONE, CONTEXT_MENU_ID_SELECT_ALL, CONTEXT_MENU_ID_SELECT_ALL, "SELECT ALL")
.setEnabled(true);
if (begin.index >= 0 && begin.index == end.index) {
switch (mSDoc.getContent(begin.index).getType()) {
case SpenContentBase.TYPE_HANDWRITING:
break;
case SpenContentBase.TYPE_DRAWING:
menu.add(Menu.NONE, CONTEXT_MENU_ID_RESIZE_IMAGE, CONTEXT_MENU_ID_RESIZE_IMAGE, "RESIZE")
.setEnabled(editable);
break;
case SpenContentBase.TYPE_IMAGE:
menu.add(Menu.NONE, CONTEXT_MENU_ID_RESIZE_IMAGE, CONTEXT_MENU_ID_RESIZE_IMAGE, "RESIZE")
.setEnabled(editable);
break;
case SpenContentBase.TYPE_VOICE:
break;
}
}
}
但是当选择这些项目时没有采取行动,这就是示例代码所具有的:
private boolean executeMenuItem(MenuItem item) {
final SpenSDoc.CursorInfo begin = mSDoc.getSelectedRegionBegin();
final SpenSDoc.CursorInfo end = mSDoc.getSelectedRegionEnd();
Log.d(TAG, "SpenContextMenuListener$executeMenuItem : " + item.getItemId() + " / " + begin.index + " - " + end.index);
switch (item.getItemId()) {
case CONTEXT_MENU_ID_CUT:
//TODO
break;
case CONTEXT_MENU_ID_COPY:
//TODO
break;
case CONTEXT_MENU_ID_PASTE:
//TODO
break;
case CONTEXT_MENU_ID_RESIZE_IMAGE: {
if (!mSDoc.isSelected()) {
return true;
}
final SpenContentBase contentImage = mSDoc.getContent(begin.index);
if (contentImage != null
&& (contentImage.getType() == SpenContentBase.TYPE_IMAGE || contentImage.getType() == SpenContentBase.TYPE_DRAWING)) {
mSpenComposerView.setResizeHandleVisible(true);
mSDoc.setCursorPosition(begin.pos > 0 ? begin : end);
mSoftInput.hide((Activity) mContext);
}
}
break;
case CONTEXT_MENU_ID_SELECT_ALL:
selectAll();
break;
}
return true;
}
如何让这些行动奏效? This是三星SDK所在的位置,包括所有示例代码。感谢您的帮助,这是我的第一篇文章,很抱歉,如果我搞砸了什么!
答案 0 :(得分:0)
@WalkingHat三星S-Pen SDK包装库不支持这些功能
适用于Android的三星S-Pen库,与Samsung SDK Pen软件包相比,只使用单一类处理大多数常见用例,但复杂性大大降低。
哪种支持:各种款式,颜色和尺寸可调的笔
尺寸可调的橡皮擦
撤消,重做
缩放
当笔悬停在边缘附近时自动滚动 画布
重复不同速度的笔画
实例缩略图生成
多页面支持
重新订购页面
彩色背景
图片背景
支持的事件:onTouch,onReplayCompleted,onPageUpdated,onCommit, 撤消,重做
使用S-Pen或手指
绘制
您需要这些
的代码