我已經實現了SwipableContainer,而且目前看起來沒有多大反應。SwipableContainer在codenameone中似乎沒有響應
當我滑動組件時,它有時卡住或輕掃左邊。有時它也不允許點擊滑動右鍵。請參閱附件快照供您參考。
有時它凍結容器滑動。另外,當它拖動右側,然後容器按鈕似乎不可點擊。一旦我將中心容器稍微向左拖動,然後右側容器的按鈕變得可點擊。
簡而言之,swipble容器的總體行爲不符合標準。
我需要在我的代碼中進行任何更改嗎?請建議。
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;
}
我想知道這是否僅在涉及多點觸摸時發生,因爲我在'SwipeableContainer'中看到了與多點觸摸有關的潛在問題。 –
@ Shai-即使只有一次觸摸,它也會發生。 – Sweety
我只能重現當第二根手指觸到某處時,是否有特定的過程來重現此問題? –