SwipableContainer在codenameone中似乎没有响应
我已经实现了SwipableContainer,目前它似乎没有太多响应 当我滑动组件时,它有时会卡住或向左滑动。有时它也不允许单击向右滑动按钮。请参阅附件中的快照以供参考 有时它会使容器在滑动时冻结。同样,当它向右拖动时,容器按钮似乎不可单击。一旦我把中央容器向左拖动一点,右边容器的按钮就可以点击了 简言之,可旋转集装箱的整体性能不合格 我需要对代码进行任何更改吗?请建议SwipableContainer在codenameone中似乎没有响应,codenameone,Codenameone,我已经实现了SwipableContainer,目前它似乎没有太多响应 当我滑动组件时,它有时会卡住或向左滑动。有时它也不允许单击向右滑动按钮。请参阅附件中的快照以供参考 有时它会使容器在滑动时冻结。同样,当它向右拖动时,容器按钮似乎不可单击。一旦我把中央容器向左拖动一点,右边容器的按钮就可以点击了 简言之,可旋转集装箱的整体性能不合格 我需要对代码进行任何更改吗?请建议 Form hi = new Form("Hi World"); hi.setLayout(new BoxLayout(Bo
Form hi = new Form("Hi World");
hi.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
hi.setScrollable(false);
TableLayout tableLayout = new TableLayout(1,5);
Container tableHeaderContainer = new Container(tableLayout);
tableHeaderContainer.setScrollable(false);
for(int col=0;col<=4;col++){
Button l1 = new Button("Header " + col+1);
l1.setVerticalAlignment(Label.TOP);
l1.setUIID("TableHeader");
l1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
final InteractionDialog dlg = new InteractionDialog("Hello");
dlg.setLayout(new BorderLayout());
dlg.addComponent(BorderLayout.CENTER, new Label("Hello Dialog"));
Button close = new Button("Close");
close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
dlg.dispose();
}
});
dlg.addComponent(BorderLayout.SOUTH, close);
Dimension pre = dlg.getContentPane().getPreferredSize();
dlg.showPopupDialog(new Rectangle((evt.getComponent().getX()+(evt.getComponent().getWidth())), (evt.getComponent().getY()+evt.getComponent().getHeight()),
evt.getComponent().getWidth(), evt.getComponent().getHeight()));
}
});
TableLayout.Constraint constraint = ((TableLayout)tableHeaderContainer.getLayout()).createConstraint();
constraint = setTableConstraint(constraint, col);
tableHeaderContainer.addComponent(constraint,l1);
}
hi.addComponent(tableHeaderContainer);
Container tableContainerMain = new Container();
tableContainerMain.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
tableContainerMain.setScrollableY(true);
for(int row=0;row<=10;row++){
Container tableContainer = new Container();
tableContainer.setLayout(new BoxLayout(BoxLayout.X_AXIS));
tableContainer.setScrollable(false);
Button actionButton = new Button();
tableLayout = new TableLayout(1,5);
final Container rowContainer = new Container(tableLayout);
Button editJobButton = new Button();
Button editJobButton1 = new Button();
Button editJobButton2 = new Button();
Button editJobButton3 = new Button();
rowContainer.setFocusable(false);
rowContainer.setLeadComponent(actionButton);
actionButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Dialog.show("actionButton", "actionButton", "OK","");
}
});
for(int col=0;col<=6;col++){
if(col==5){
editJobButton = new Button();
editJobButton.setIcon(theme.getImage("edit.png"));
editJobButton.setPressedIcon(theme.getImage("edit-lg.png"));
editJobButton.setDisabledIcon(theme.getImage("edit-gr.png"));
editJobButton.setUIID("transparent_button_action_new");
editJobButton.setVerticalAlignment(Label.TOP);
editJobButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
}
});
editJobButton1 = new Button();
editJobButton1.setIcon(theme.getImage("synch1.png"));
editJobButton1.setPressedIcon(theme.getImage("synch-lg.png"));
editJobButton1.setDisabledIcon(theme.getImage("synch-gr.png"));
editJobButton1.setUIID("transparent_button_action_new");
editJobButton1.setVerticalAlignment(Label.TOP);
editJobButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
}
});
editJobButton2 = new Button();
editJobButton2.setIcon(theme.getImage("map1.png"));
editJobButton2.setPressedIcon(theme.getImage("map-lg.png"));
editJobButton2.setUIID("transparent_button_action_new");
editJobButton2.setVerticalAlignment(Label.TOP);
editJobButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
}
});
editJobButton3 = new Button();
editJobButton3.setIcon(theme.getImage("checkin.png"));
editJobButton3.setPressedIcon(theme.getImage("checkin-lg.png"));
editJobButton3.setDisabledIcon(theme.getImage("checkin-gr.png"));
editJobButton3.setUIID("transparent_button_action_new");
editJobButton3.setVerticalAlignment(Label.TOP);
editJobButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
}
});
}
else{
SpanLabel l2 = new SpanLabel(“This is testing text, This is testing text , This is testing text This is testing text " + (col+1));
l2.setTextUIID("login_title");
l2.setUIID("transparent");
TableLayout.Constraint constraint1 = ((TableLayout)rowContainer.getLayout()).createConstraint();
constraint1 = setTableConstraint(constraint1, col);
rowContainer.addComponent(constraint1,l2);
}
}
SwipeableContainer swipeableContainer = new SwipeableContainer(null,BoxLayout.encloseX(editJobButton,editJobButton1,editJobButton2,editJobButton3), rowContainer);
CheckBox c = new CheckBox();
tableContainer.addComponent(c);
tableContainer.addComponent(swipeableContainer);
tableContainerMain.addComponent(tableContainer);
}
hi.addComponent(tableContainerMain);
hi.show();
public static Constraint setTableConstraint(Constraint constraint,int column){
switch(column){
case 0:
constraint.setWidthPercentage(20);//job#
break;
case 1:
constraint.setWidthPercentage(20);//Address
break;
case 2:
constraint.setWidthPercentage(20);//Schedule Date
break;
case 3:
constraint.setWidthPercentage(20);//Type
break;
case 4:
constraint.setWidthPercentage(20);//Status
break;
default:
constraint.setWidthPercentage(20);//else
break;
}
return constraint;
}
formhi=新表单(“hi-World”);
hi.setLayout(新的BoxLayout(BoxLayout.Y_轴));
hi.setScrollable(假);
TableLayout TableLayout=新的TableLayout(1,5);
Container tableHeaderContainer=新容器(tableLayout);
tableHeaderContainer.setScrollable(假);
对于(int col=0;col而言,问题在于您在使用lead组件时设置为不可聚焦的rowContainer
当您在容器上使用setFocusable(false)
时,您要求容器不要响应触摸事件,将此与将引线组件设置为可接收触摸事件的按钮相结合将导致异常行为
另外,rowContainer
不包含作为主要组件的actionButton
移除rowContainer.setFocusable(false)
,离开setLeadComponent
,确保容器中添加了actionButton
。然后检查这是否解决了问题。我想知道这是否仅在涉及多点触摸时才会发生,因为我在SwipeableContainer
@Shai中看到了一些与多点触摸相关的潜在问题-即使在单次触碰。我只能在食指触碰某处时再现该问题,是否有特定的过程再现该问题?@Shai-可以给我示例代码吗?这对您有效。我使用了您发送给我们的此示例。我只能在两个手指同时触碰设备时再现该问题。@Diamond-我已删除rowContainer。setFocusable(false)并已将actionButton添加为setLeadComponent(actionButton)。是否还有其他需要检查的内容?问题仍未解决。是的,只有在设备上运行此代码时才会发生。