我从创建一个对话框类包含一个TextArea:LWUIT 1.4:为什么在这个TextArea中有时会有重复?
public class Alert extends Dialog {
private Container c = new Container(new BorderLayout());
private Label titre = new Label("Mobile Banking");
private TextArea chp;
private Command[] comms;
public Alert(String text, Command[] comms)
{
super();
titre.setUIID("titre_alert");
titre.setAlignment(Label.CENTER);
this.comms = comms;
setAutoDispose(true);
for (int cmd=0; cmd<comms.length; cmd++)
addCommand(comms[cmd]);
chp = new TextArea();
chp.setEditable(false);
chp.setAlignment(Label.CENTER);
chp.getSelectedStyle().setBorder(null);
chp.getUnselectedStyle().setBorder(null);
chp.getSelectedStyle().setBgColor(this.getStyle().getBgColor());
chp.getUnselectedStyle().setBgColor(this.getStyle().getBgColor());
if (text.length() % 2 != 0)
text = " ".concat(text);
while (text.substring(0, (text.length()/2)+1).length() < chp.getMaxSize()/2)
{
text = " ".concat(text);
}
chp.setText(text);
c.addComponent(BorderLayout.NORTH, titre);
c.addComponent(BorderLayout.CENTER, chp);
}
public Command affiche()
{
return show(null, c, comms);
}
}
一个表单内我启动一个线程,这使得一个HttpConnection的电话和其他任务。如果任务成功结束,然后我把上面的类Alert
的affiche()
方法:
alert = new Alert("Chargement effectué avec succès !", new Command[]{ok});
cntnr.removeComponent(cPatienter); // container displaying the "please wait..."
repaint(); // repainting the Form
if (alert.affiche() == ok) // showing the confirmation of successfullness of the task
{
alert.dispose();
controller.displayScreen("Menuprincipale");
}
的问题是,有时,调用affiche()
方法被复制时所显示的文本:它应该只显示文本Chargement effectué avec succès !
但有时会显示文字,还有Chargement effectué
。
那么如何让它只显示文本参数但不能重复?
_“但有时它会显示文本和”_,在哪种情况下会产生此错误? – Vimal
这种情况是不可预知的:但Thread执行的任务是一个httpconnection,它将数据从PC下载到手机。 – pheromix