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
Posts: 138
Registered: ‎04-19-2012
My Device: No
My Carrier: Nokia
Accepted Solution

How to use Thread in infinite ListField

[ Edited ]
This is my code of listfield . 
package mypackage;

import net.rim.device.api.command.CommandHandler;
import net.rim.device.api.command.ReadOnlyCommandMetadata;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.component.table.SimpleList;
import net.rim.device.api.ui.container.MainScreen;

public class SimpleListDemo extends UiApplication {
	public static void main(String[] args) {
		SimpleListDemo theApp = new SimpleListDemo();
		theApp.enterEventDispatcher();
	}

	public SimpleListDemo() {
		pushScreen(new SimpleListScreen());
	}

	class SimpleListScreen extends MainScreen {
		private SimpleList listField;

		public SimpleListScreen() {
			super(Manager.NO_VERTICAL_SCROLL);
			setTitle("Simple List Demo");
			add(new LabelField("Blackberry Team", LabelField.FIELD_HCENTER));
			add(new SeparatorField());
			Manager mainManager = getMainManager();
			mainManager.setMargin(0, 0, 0, 50);

			listField = new SimpleList(mainManager);

Thread th = new Thread()
{



public void run()
{
try
{
listField.add("Mr.Sushil");
Thread.sleep(1000);
listField.add("Mr.Anantha");
Thread.sleep(1000);
listField.add("Mr.Himanshu");
}




catch(Exception e)
{
}



UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
}});
}};
th.start();

			listField.setCommand(new CommandHandler() {

				public void execute(ReadOnlyCommandMetadata metadata,
						Object context) {

					if (listField.getFocusRow() == 0) {
						UiApplication.getUiApplication().pushScreen(new P());
					}

				}
			}, null, null);

		}

		
	}

}

 

Highlighted
Trusted Contributor
Posts: 138
Registered: ‎04-19-2012
My Device: No
My Carrier: Nokia

Re: How to use Thread in infinite ListField

I want to using thread , simply thread is working in that .but i am looking for infinite listfield's.

 

My list item should be displayed like that after every one second.

 

item1

item2

item3

.

.

.

.

.item n

Trusted Contributor
Posts: 138
Registered: ‎04-19-2012
My Device: No
My Carrier: Nokia

Re: How to use Thread in infinite ListField

got the solution.