我想知道如何在搜索后动态更改表单,我有:
Form hi = new Form("Soggetti");
BoxLayout b=new BoxLayout(BoxLayout.Y_AXIS);
TableLayout ttt=new TableLayout(10,1);
int ttt_height=20;
ttt.setDefaultRowHeight(ttt_height);
ttt.setDefaultColumnWidth(100);
hi.setLayout(ttt);
MultiButton bbb=new MultiButton();
bbb.setTextLine1("Soggetto 1");
bbb.setTextLine2("Dettagli ");
bbb.setIcon(i);
bbb.setEmblem(s);
MultiButton bbb2=new MultiButton();
bbb2.setTextLine1("Soggetto 1");
bbb2.setTextLine2("Dettagli ");
bbb2.setIcon(i);
bbb2.setEmblem(s);
MultiButton bbb3=new MultiButton();
bbb3.setTextLine1("Soggetto 1");
bbb3.setTextLine2("Dettagli ");
bbb3.setIcon(i);
bbb3.setEmblem(s);
bbb2.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent evt) {
int p=1;
p++;
// TODO Auto-generated method stub
// bbb3.setVisible(true);
hi.removeAll();
//hi = new Form("Soggetti");
BoxLayout b=new BoxLayout(BoxLayout.Y_AXIS);
TableLayout ttt=new TableLayout(10,1);
int ttt_height=5;
ttt.setDefaultRowHeight(ttt_height);
ttt.setDefaultColumnWidth(100);
hi.setLayout(ttt);
//ci ricreiamo i i bottoni precedenti
hi.addComponent(bbb);
hi.addComponent(bbb2);
ArrayList<LinkedHashMap> alhm= Ricerca("");
Label contatto=null;
for(int j=0;j<alhm.size();j++){
LinkedHashMap s=alhm.get(j);
String nome=(String) s.get("firstName");
String cognome=(String) s.get("lastName");
String numero =(String) s.get("numero");
contatto=new Label(nome+" "+cognome+" "+numero);
Double id= (Double) s.get("id");
hi.addComponent(contatto);
}
hi.addComponent(bbb3);
// SchermataRubrica sr=new SchermataRubrica();
// sr.getSchermata();
hi.show();
}
});
hi.addComponent(bbb);
hi.addComponent(bbb2);
hi.addComponent(bbb3);
hi.addCommand(Schermata1);
hi.addCommand(Schermata2);
hi.addCommand(Schermata3);
hi.show();
当单击多按钮bbb2时,我想在多按钮下方显示结果,但它却搞砸了所有......可能我在逻辑层面上遗漏了某些东西...... 谢谢
答案 0 :(得分:0)
使用hi.show()
替换结果中的hi.revalidate()
。
我可能不会将TableLayout用于搜索结果,并会选择BoxLayout
。在这里查看我们的就地搜索,它可能不是您需要的,但应该给您一个提示:https://www.codenameone.com/blog/building-a-chat-app-with-codename-one-part-4.html
您还可以使用animateUnlayout
和animateLayout
很好地动画删除/添加组件。