Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
jaff
Posts: 115
Registered: ‎11-16-2011
My Device: Smartphone Storm 9900

how to update ui manager from thread?

im succses to update single field... and try to update more field...but just result a single field to...

 

code UI :

 

public Company() {

       perusahaan = new LabelField();
       add(perusahaan);

 

 

code update UI on thread :

final int y = x;
						dataAdd[y]=address.getString(y);
						dataId[y]=id_comp.getString(y);
						final String alamat = dataAdd[y].toString();
						final String idperus = dataId[y].toString();
						
						UiApplication.getUiApplication().invokeLater(new Runnable(){
							public void run(){
								perusahaan.setText( perusahaan.getText() + y + alamat);

 code above succses input data array to labelfield "perusahaan"

 

and now im try to update this UI :

 

public company() {
hfm = new HorizontalFieldManager[mystring.length()]; for(int i=0;i<mystring.length();i++) { dataComp[i]=mystring.getString(i); hfm[i] = new HorizontalFieldManager(Field.USE_ALL_WIDTH); perusahaan = new LabelField(); hfm[i].add(perusahaan);
  add(hfm[i])
}

 i try but result empty blank on top... and result like before in bottom...

i mean i want to put one string from array to one label...so i can manage that...

 

any solution?

Developer
jitendrasharma
Posts: 208
Registered: ‎08-04-2009
My Device: Not Specified

Re: how to update ui manager from thread?

Use LabelField as local to For loop and your problem will get resolved.

 

public company() {
        hfm = new HorizontalFieldManager[mystring.length()];
			for(int i=0;i<mystring.length();i++)
			{
				dataComp[i]=mystring.getString(i);
				hfm[i] = new HorizontalFieldManager(Field.USE_ALL_WIDTH);
				LabelField perusahaan = new LabelField();
				hfm[i].add(perusahaan);
                                add(hfm[i])      
                         }

 

Trusted Contributor
jaff
Posts: 115
Registered: ‎11-16-2011
My Device: Smartphone Storm 9900

Re: how to update ui manager from thread?

emmh...still error...

im try to implements your code in class InfoStore ... in my UI not in ListField

above is my UI code.... 

 

can i make UI on void run() on the thread?

Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: how to update ui manager from thread?

Why are you using perusahaan in your last loop? You are losing the reference to the first LabelField you've added to Company. You can simply write hfm[i].add(new LabelField()); instead of the two lines before add(hfm[i]) to achieve exactly the same result and preserve your perusahaan value.

 

Besides, you are adding empty LabelFields in that look - is this what you want? Both the code and your explanation are very unclear, so if you could elaborate on what exactly you are trying to achieve we could help better.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!