i added two button fields to a Horizontal Manager and when i try to delete the same from the manager from a different thread i get an - index out of bounds exception.
Here is an example of what i did--
hfm.add(button1);
hfm.add(button2);
layout.add(hfm);
// on clicking button it starts a different thread which
// tries to delete the two buttonFields from the manager.
fieldChanged(Field field1,int arg1) {
if(field1==button1) {
populateUI();//This function starts a new Thread
}
}
populateUI() {
//...............//
run() {
//...............//
hfm.deleteAll();//this line gives an exception whereas
//on applying debu开发者_StackOverflow中文版g it shows field count as 2
}
}
So why is it showing error even when it has fields in it??? The rest everything are working fine.
i even tried deleting it individually...
hfm.delete(0);
hfm.delete(1);
but still the same error -- index out of bounds exception
You can use :
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
HorizontalFieldManager newHfm = new HorizontalFieldManager();
replace ( hfm , newHfm );
}
});
and voila! your hfm is good as new..
精彩评论