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
Contributor
grendal100
Posts: 10
Registered: ‎10-30-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: Listfield Issue

That's ok ... had me thinking I'd made a mistake :smileyhappy:

 

Easier maybe to post some code so you can see what drawListRow is doing.

 

public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
		MovementsList list = (MovementsList) listField;
		TableRowManager rowManager = (TableRowManager) list.rows.elementAt(index);
		int w = widthNum + widthProduct + widthQuantity + widthUOM + widthBooking + widthDate + widthWeighbridge + widthContract + widthMovement + widthCarrier + widthVehicleReg;
		rowManager.drawRow(g, 0, y, w, subHeight);
	}

 I would assume that the width being passed in is the screen width (but I may be wrong) but in rowManager (TableRowManager) I pass a calculated width to drawRow based on the fields contained within.

 

I've just tried your experiment. I scrolled to the end of the first row, cleared the log, and then scrolled down to row 2 and the following was seen in the log:

 

HFM Current H:1540, V:0
VFM Current H:0, V:0
VFM Current H:0, V:0
HFM Current H:1540, V:0

If I the scroll to the end of row 2, VFM still shows 0,0 and HFM still shows 1540,0.

 

Is this what you would have expected to see? I would have thought that if the HFM was performing the scroll back, it's HorizontalScroll value would have reset to 0

Please use plain text.
Contributor
grendal100
Posts: 10
Registered: ‎10-30-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: Listfield Issue

Also to add, I tried changing the x value on rowManager.drawRow (which I have as 0) and this just offset the start of the row which doesn't help as it then doesn't tie up with the column headers.

Also, the numbers in the log are from using the nav button. If I use the touchscreen, nothing is put into the log at all
Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Listfield Issue

Interesting results.

 

To make it a little clearer, can you change the debugging to distinguish between the requests made from the VFM and HFM (actually you have already done that) and the pre and post super. call. Something like:

 

protected void navigationMovement(...) {

System.out,println("HFM Pre H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());

super....

System.out,println("HFM Post H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());

}

 

However, this is not showing what I would expect.  Like you I would expect the HFM to be reset to 0. 

 

Can you please check the width that you being passed in to drawListRow to confirm that it is the screen width. 

 

Also, when the scroll back occurs, does the 'header' TableLayoutManager also get scrolled back.  I am sure the answer is yes, just wanted to confirm. 

 

I'm still struggling to determine what moves the screen back.....  There is loads more 'debugging' that I could ask you to do, like displaying the scroll position in the Mangers paint methods, but I suspect it is probably time for either:

a) Someone else who understands this better to have a look, or

b) Me to have a play with something similar myself.

 

Can you confirm the JDE level you are using to develop and the OS level of the Simulator you are using. 

Please use plain text.
Developer
simon_hain
Posts: 15,806
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Listfield Issue

i would suggest to use listfield as intended. if that is not sufficient, use other fields, my guess would be that the internal controllers of listfield cause issues here.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
grendal100
Posts: 10
Registered: ‎10-30-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: Listfield Issue

No disrespect, Simon, but I felt that is what I was doing. Sure, each row has many bits of data within it, but ultimately it's just a list. It could be one field which extends past the edge of the screen, the same behaviour could be seen :smileyhappy:

 

Anyway, same test as before, results are as follows:

 

HFM after Current H:1540, V:0
VFM after Current H:0, V:0
VFM before Current H:0, V:0
HFM Before Current H:1540, V:0

The only value that ever changes is the HFM HorizontalScroll value. As I mentioned before, this increments as I scroll right, then stays at 1540.

 

You are correct. When the scroll back occurs, the headers do indeed scroll back.

 

And the width that is passed to drawListRow is the row width ie the acculumation of the widths of all the columns.

 

As for OS level, that's OS 5.0.0. As for JDE level, not sure what you mean by that (showing my inexperience here) but the Eclipse plug in version is 1.5.0, Java SDK version is 5.0.0.36.

 

Apologies for the length of this post but I'm unable to add attachments and wished to include a sample of the code which I'm using. I've tested this in my app and it demonstrates the issue.

 

Firstly, the screen:

 

package Screens;

import java.util.Vector;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.BackgroundFactory;
import ListFieldObjects.TableList;
import Main.Stoppable;
import Main.TableLayoutManager;

public class TableScreen extends MainScreen implements FieldChangeListener 
{
	VerticalFieldManager vfmScreen, vfmTable, vfmPlanned, vfmActual;
	HorizontalFieldManager hfmTableTitle;
	public Vector vectorData;
	TableList tableList;
	int numData=0;
	int subHeight = 0;
	LabelField lblTableTitle, lblField01, lblField02, lblField03, lblField04, lblField05, lblField06, lblField07, lblField08, lblField09;
	Screen currScreen;
	boolean refresh=false;
	public static boolean _stop = false;
	TableLayoutManager tlmNumData;
	Font buttonFont;
	static int widthField01=65, widthField02=150, widthField03=150, widthField04=150, widthField05=150, widthField06=150, widthField07=150, widthField08=150, widthField09=150;
	
	
	public TableScreen()
	{
		super(USE_ALL_WIDTH | USE_ALL_HEIGHT);
		
		vfmScreen = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH);
		vfmScreen.deleteAll();
		
		switch (Display.getWidth()) {
			case 640:
				subHeight = 40;
				buttonFont = Font.getDefault().derive(Font.SANS_SERIF_STYLE | Font.BOLD, 6, Ui.UNITS_pt);
				break;
			default:
				subHeight = 30;
				buttonFont = Font.getDefault().derive(Font.SANS_SERIF_STYLE | Font.BOLD, 7, Ui.UNITS_pt);
				break;
		}
		
		_stop = false;

		HorizontalFieldManager hfmTitle = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.NON_FOCUSABLE) {
			protected void sublayout( int maxWidth, int maxHeight)
    		{
        		int width = Display.getWidth();
    		    int height = subHeight;
    		    super.sublayout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(0x00fec200));
    		    setExtent( width, height);
    		}
		};
		hfmTitle.setPadding(0, 1, 0, 1);

		// create a label
		LabelField title = new LabelField("Data", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
		title.setFont(Font.getDefault().derive(Font.SANS_SERIF_STYLE | Font.BOLD, 7, Ui.UNITS_pt));
		hfmTitle.add(title);

		vfmScreen.add(hfmTitle);	
		currScreen = UiApplication.getUiApplication().getActiveScreen();
		
		vectorData = new Vector();
		numData = 0;
		
		refresh=true;		
		getData RunnableGetData = new getData();
		PleaseWaitPopupScreen.showScreenAndWait(RunnableGetData, "Retrieving Data");				
		
		if (_stop)
		{
			numData = vectorData.size();        	
        	showHeaders();
		}
		
		add(vfmScreen);
	}
	
	public void fieldChanged(Field field, int context) {
		// TODO Auto-generated method stub		
	}
	
	class getData implements Runnable, Stoppable
	{		
		public void run()
		{	
			vectorData.addElement(new data("data 1, 1", "data 1, 2", "data 1, 3", "data 1, 4", "data 1, 5", "data 1, 6", "data 1, 7", "data 1, 8", "data 1, 9"));
			vectorData.addElement(new data("data 2, 1", "data 2, 2", "data 2, 3", "data 2, 4", "data 2, 5", "data 2, 6", "data 2, 7", "data 2, 8", "data 2, 9"));
			vectorData.addElement(new data("data 3, 1", "data 3, 2", "data 3, 3", "data 3, 4", "data 3, 5", "data 3, 6", "data 3, 7", "data 3, 8", "data 3, 9"));
			vectorData.addElement(new data("data 4, 1", "data 4, 2", "data 4, 3", "data 4, 4", "data 4, 5", "data 4, 6", "data 4, 7", "data 4, 8", "data 4, 9"));
			vectorData.addElement(new data("data 5, 1", "data 5, 2", "data 5, 3", "data 5, 4", "data 5, 5", "data 5, 6", "data 5, 7", "data 5, 8", "data 5, 9"));
			vectorData.addElement(new data("data 6, 1", "data 6, 2", "data 6, 3", "data 6, 4", "data 6, 5", "data 6, 6", "data 6, 7", "data 6, 8", "data 6, 9"));
			vectorData.addElement(new data("data 7, 1", "data 7, 2", "data 7, 3", "data 7, 4", "data 7, 5", "data 7, 6", "data 7, 7", "data 7, 8", "data 7, 9"));
			vectorData.addElement(new data("data 8, 1", "data 8, 2", "data 8, 3", "data 8, 4", "data 8, 5", "data 8, 6", "data 8, 7", "data 8, 8", "data 8, 9"));
	        
			final Stoppable ourProcessing = this;
	        UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {	
                	
    				numData = vectorData.size();
                	
                	showHeaders();
        			showData();
        			refresh=false;
        			
    				if (numData > 0)
        			{
    					tableList = new TableList(vectorData);
                    	vfmTable.add(tableList);
                    	tableList.setFocus();
        			}
        			else
        				tableList = null; 
                }
  			});
		}

		public boolean stop() {
			// TODO Auto-generated method stub
			_stop = true;
			UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());
			return false;
		}

		public boolean isStopped() {
			// TODO Auto-generated method stub
			return _stop;
		}
	}	
	
	private void showHeaders()
	{	
		hfmTableTitle = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH | HorizontalFieldManager.NO_HORIZONTAL_SCROLL  | HorizontalFieldManager.NO_VERTICAL_SCROLL) {
			protected void sublayout( int maxWidth, int maxHeight)
    		{
        		int width = Display.getWidth();
    		    int height = subHeight+5;
    		    super.sublayout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.SILVER));
    		    setExtent( width, height);
    		}
		};
		lblTableTitle = new LabelField("" + vectorData.size() + " rows", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER | DrawStyle.VCENTER);
		lblTableTitle.setPadding(2,2,2,2);
		lblTableTitle.setFont(Font.getDefault().derive(Font.BOLD, 7, Ui.UNITS_pt));
		hfmTableTitle.add(lblTableTitle);
		vfmScreen.add(hfmTableTitle);
	}
	
	private void showData()
	{
		Font fontLblTitle = Font.getDefault().derive(Font.BOLD, 7, Ui.UNITS_pt);
		String label01="", label02="", label03="", label04="", label05="", label06="", label07="", label08="", label09="", label10="", label11="";
		
		HorizontalFieldManager hfmTable = new HorizontalFieldManager(HorizontalFieldManager.HORIZONTAL_SCROLL | HorizontalFieldManager.HORIZONTAL_SCROLLBAR | HorizontalFieldManager.NO_SCROLL_RESET | HorizontalFieldManager.NON_FOCUSABLE) {
			
			protected void drawFocus(Graphics g, boolean on) {
				System.out.println("HFM drawFocus");
			}
			   
			   protected boolean navigationMovement(int dx, int dy, int status, int time) {
				   System.out.println("HFM before Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
				   super.navigationMovement(dx, dy, status, time);
				   System.out.println("HFM after Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
				   return false;
			   }
		};
		vfmTable = new VerticalFieldManager(VerticalFieldManager.NO_HORIZONTAL_SCROLL | VerticalFieldManager.NO_HORIZONTAL_SCROLLBAR | VerticalFieldManager.NO_VERTICAL_SCROLL | VerticalFieldManager.NO_VERTICAL_SCROLLBAR | VerticalFieldManager.NO_SCROLL_RESET | VerticalFieldManager.NON_FOCUSABLE)
		{
			   protected void sublayout( int maxWidth, int maxHeight )
			   {
			       //set your width
			       int width = widthField01 + widthField02 + widthField03 + widthField04 + widthField05 + widthField06 + widthField07 + widthField08 + widthField09;
			       //set your height
			       int height = (vectorData.size() + 1) * subHeight;
			 
			       super.sublayout( width, height);
			       setExtent( width, height);
			       setFocus(200, 0, 0);
			   }
			   
			   protected boolean navigationMovement(int dx, int dy, int status, int time) {
				   System.out.println("VFM before Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
				   super.navigationMovement(dx, dy, status, time);
				   System.out.println("VFM after Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
				   return false;
			   }
		};
		vfmTable.setPadding(0,0,0,0);		

		TableLayoutManager tblTableRows;
		
		label01 = "   #";
		label02 = "Column 1";
		label03 = "Column 2";
		label04 = "Column 3";
		label05 = "Column 4";
		label06 = "Column 5";
		label07 = "Column 6";
		label08 = "Column 7";
		label09 = "Column 8";
		
		tblTableRows = new TableLayoutManager(new int[] { TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH,
														  TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH,
														  TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH, TableLayoutManager.FIXED_WIDTH },
											  new int[] { widthField01, widthField02, widthField03, widthField04, widthField05, widthField06, widthField07, widthField08, widthField09 },
											  0,
											  Manager.NO_HORIZONTAL_SCROLL | Manager.NO_VERTICAL_SCROLL | Manager.NO_SCROLL_RESET);
		

		lblField01 = new LabelField(label01, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
			protected void layout( int maxWidth, int maxHeight)
    		{
        		int width = widthField01;
    		    int height = subHeight;
    		    super.layout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
    		    setExtent( width, height);
    		}
		};
		lblField01.setFont(fontLblTitle);
		tblTableRows.add(lblField01);	
					
		lblField02 = new LabelField(label02, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
			protected void layout( int maxWidth, int maxHeight)
    		{
        		int width = widthField02;
    		    int height = subHeight;
    		    super.layout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
    		    setExtent( width, height);
    		}
		};
		lblField02.setFont(fontLblTitle);
		tblTableRows.add(lblField02);	
		
		lblField03 = new LabelField(label03, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
			protected void layout( int maxWidth, int maxHeight)
    		{
        		int width = widthField03;
    		    int height = subHeight;
    		    super.layout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
    		    setExtent( width, height);
    		}
		};
		lblField03.setFont(fontLblTitle);
		tblTableRows.add(lblField03);			
		
		lblField04 = new LabelField(label04, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
			protected void layout( int maxWidth, int maxHeight)
    		{
        		int width = widthField04;
    		    int height = subHeight;
    		    super.layout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
    		    setExtent( width, height);
    		}
		};
		lblField04.setFont(fontLblTitle);
		tblTableRows.add(lblField04);		
		
		lblField05 = new LabelField(label05, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
			protected void layout( int maxWidth, int maxHeight)
    		{
        		int width = widthField05;
    		    int height = subHeight;
    		    super.layout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
    		    setExtent( width, height);
    		}
		};
		lblField05.setFont(fontLblTitle);
		tblTableRows.add(lblField05);			
		
		lblField06 = new LabelField(label06, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
			protected void layout( int maxWidth, int maxHeight)
    		{
        		int width = widthField06;
    		    int height = subHeight;
    		    super.layout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
    		    setExtent( width, height);
    		}
		};
		lblField06.setFont(fontLblTitle);
		tblTableRows.add(lblField06);			
		
		lblField07 = new LabelField(label07, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
			protected void layout( int maxWidth, int maxHeight)
    		{
        		int width = widthField07;
    		    int height = subHeight;
    		    super.layout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
    		    setExtent( width, height);
    		}
		};
		lblField07.setFont(fontLblTitle);
		tblTableRows.add(lblField07);			
		
		lblField08 = new LabelField(label08, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
			protected void layout( int maxWidth, int maxHeight)
    		{
        		int width = widthField08;
    		    int height = subHeight;
    		    super.layout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
    		    setExtent( width, height);
    		}
		};
		lblField08.setFont(fontLblTitle);
		tblTableRows.add(lblField08);			
		
		lblField09 = new LabelField(label09, LabelField.HCENTER | LabelField.FIELD_VCENTER) {
			protected void layout( int maxWidth, int maxHeight)
    		{
        		int width = widthField09;
    		    int height = subHeight;
    		    super.layout( width, height);
    		    super.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
    		    setExtent( width, height);
    		}
		};
		lblField09.setFont(fontLblTitle);
		tblTableRows.add(lblField09);
		
		vfmTable.add(tblTableRows);
		hfmTable.add(vfmTable);
		vfmScreen.add(hfmTable);		
	}
    
    public static class data {
    	// In this example, to save accessors, the names are public
    	public String datafield01=null, datafield02=null, datafield03=null, datafield04=null, datafield05=null, datafield06=null, datafield07=null, datafield08=null, datafield09=null;
    	
		public data(String field1, String field2, String field3, String field4, String field5, String field6, String field7, String field8, String field9) 
    	{
			datafield01 = field1;
			datafield02 = field2;
			datafield03 = field3;
			datafield04 = field4;
			datafield05 = field5;
			datafield06 = field6;
			datafield07 = field7;
			datafield08 = field8;
    	}
    }
}

 And now the ListField

 

package ListFieldObjects;

import java.util.Vector;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;
import Screens.TableScreen.data;

public class TableList extends ListField implements ListFieldCallback {

	private Vector rows;
	Vector vectorData;
    TableRowManager row;
    String optionType;
    int subHeight = 0;
    Font fontTable;
	int widthField01=65, widthField02=150, widthField03=150, widthField04=150, widthField05=150, widthField06=150, widthField07=150, widthField08=150, widthField09=150, widthField10=150, widthField11=150, widthField12=150;

	public TableList(Vector v) {
		super(0, ListField.USE_ALL_WIDTH | ListField.FOCUSABLE);
		
		switch (Display.getWidth()) {
			case 640:
				fontTable = Font.getDefault().derive(Font.SANS_SERIF_STYLE, 5, Ui.UNITS_pt);
				subHeight = 40;
				break;
			default:
				fontTable = Font.getDefault().derive(Font.SANS_SERIF_STYLE, 6, Ui.UNITS_pt);
				subHeight = 30;
				break;
		};

		setRowHeight(subHeight);
		setCallback(this);

		rows = new Vector();		
		vectorData = v;
		
		for (int i=0;i<vectorData.size();i++)
		{
			String field1=null, field2=null, field3=null, field4=null, field5=null, field6=null, field7=null, field8=null, field9=null;
			
			data d = (data) vectorData.elementAt(i);
			if (d.equals(null))
				continue;
				
			field1  = ""+(i+1);
			field2  = d.datafield01;
			field3  = d.datafield02;
			field4  = d.datafield03;
			field5  = d.datafield04;
			field6  = d.datafield05;
			field7  = d.datafield06;
			field8  = d.datafield07;
			field9  = d.datafield08;
						
			row = new TableRowManager();
			if (!field1.equals(null))
			{
				LabelField lblField1 = new LabelField(field1, LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER | LabelField.FOCUSABLE);
				lblField1.setFont(fontTable);
				row.add(lblField1);
			}
			if (!field2.equals(null))
			{
				LabelField lblField2 = new LabelField(field2, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
				lblField2.setFont(fontTable);
				row.add(lblField2);
			}
			if (!field3.equals(null))
			{	
				LabelField lblField3 = new LabelField(field3, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
				lblField3.setFont(fontTable);
				row.add(lblField3);			
			}
			if (!field4.equals(null))
			{	
				LabelField lblField4 = new LabelField(field4, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
				lblField4.setFont(fontTable);
				row.add(lblField4);			
			}
			if (!field5.equals(null))
			{	
				LabelField lblField5 = new LabelField(field5, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
				lblField5.setFont(fontTable);
				row.add(lblField5);			
			}
			if (!field6.equals(null))
			{	
				LabelField lblField6 = new LabelField(field6, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
				lblField6.setFont(fontTable);
				row.add(lblField6);			
			}
			if (!field7.equals(null))
			{	
				LabelField lblField7 = new LabelField(field7, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
				lblField7.setFont(fontTable);
				row.add(lblField7);			
			}
			if (!field8.equals(null))
			{	
				LabelField lblField8 = new LabelField(field8, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
				lblField8.setFont(fontTable);
				row.add(lblField8);			
			}
			if (!field9.equals(null))
			{	
				LabelField lblField9 = new LabelField(field9, LabelField.HCENTER | LabelField.FIELD_VCENTER | LabelField.FOCUSABLE);
				lblField9.setFont(fontTable);
				row.add(lblField9);			
			}
			rows.addElement(row);
		}

		setSize(rows.size());
	}

	// ListFieldCallback Implementation
	public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
		System.out.println("drawListRow; index="+index+"; y="+y+"; width="+width);
		TableList list = (TableList) listField;
		TableRowManager rowManager = (TableRowManager) list.rows.elementAt(index);
		int w = widthField01 + widthField02 + widthField03 + widthField04 + widthField05 + widthField06 + widthField07 + widthField08 + widthField09;
		rowManager.drawRow(g, 0, y, w, subHeight);
	}

	private class TableRowManager extends Manager {
		public TableRowManager() {
			super(0);
		}
		
		// Causes the fields within this row manager to be layed out then
		// painted.
		public void drawRow(Graphics g, int x, int y, int width, int height) {
			// Arrange the cell fields within this row manager.
//			layout(width, height);
			layout(width, height);

			// Place this row manager within its enclosing list.
			setPosition(x, y);

			// Apply a translating/clipping transformation to the graphics
			// context so that this row paints in the right area.
			g.pushRegion(getExtent());

			// Paint this manager's controlled fields.
			subpaint(g);

			g.setColor(0x00CACACA);
			g.drawLine(0, 0, getPreferredWidth(), 0);

			// Restore the graphics context.
			g.popContext();
		}

		// Arranges this manager's controlled fields from left to right within
		// the enclosing table's columns.
		protected void sublayout(int width, int height) {
			// set the size and position of each field.
//			int preferredWidth = getPreferredWidth();
			Field field;
			int xVal=1, yVal=3, fieldWidth=0;
			
			field = getField(0);
			if (!field.equals(null))
			{	
				fieldWidth = widthField01;
				layoutChild(field, fieldWidth, subHeight);
				setPositionChild(field, xVal, yVal);
				xVal = xVal + fieldWidth;
			}
			
			// start with the Bitmap Field of the priority icon
			field = getField(1);
			if (!field.equals(null))
			{	
				fieldWidth = widthField02;
				layoutChild(field, fieldWidth, subHeight);
				setPositionChild(field, xVal, yVal);
				xVal = xVal + fieldWidth;
			}
			
			// set the list name label field
		  	field = getField(2);
			if (!field.equals(null))
			{	
				fieldWidth = widthField03;
			  	layoutChild(field, fieldWidth, subHeight);
			  	setPositionChild(field, xVal, yVal);
				xVal = xVal + fieldWidth;					
			}
		  	
		  	// set the list name label field
		  	field = getField(3);
			if (!field.equals(null))
			{	
				fieldWidth = widthField04;
			  	layoutChild(field, fieldWidth, subHeight);
			  	setPositionChild(field, xVal, yVal);
				xVal = xVal + fieldWidth;					
			}
		  	
		  	// set the list name label field
		  	field = getField(4);
			if (!field.equals(null))
			{	
				fieldWidth = widthField05;
			  	layoutChild(field, fieldWidth, subHeight);
			  	setPositionChild(field, xVal, yVal);
				xVal = xVal + fieldWidth;					
			}
		  	
		  	// set the list name label field
		  	field = getField(5);
			if (!field.equals(null))
			{	
				fieldWidth = widthField06;
			  	layoutChild(field, fieldWidth, subHeight);
			  	setPositionChild(field, xVal, yVal);
				xVal = xVal + fieldWidth;					
			}
		  	
		  	// set the list name label field - Product
		  	field = getField(6);
			if (!field.equals(null))
			{	
				fieldWidth = widthField07;
			  	layoutChild(field, fieldWidth, subHeight);
			  	setPositionChild(field, xVal, yVal);	
				xVal = xVal + fieldWidth;				
			}
		  	
		  	// set the list name label field
		  	field = getField(7);
			if (!field.equals(null))
			{		
				fieldWidth = widthField08;
			  	layoutChild(field, fieldWidth, subHeight);
			  	setPositionChild(field, xVal, yVal);
				xVal = xVal + fieldWidth;				
			}
		  	
		  	// set the list name label field
		  	field = getField(8);
			if (!field.equals(null))
			{	
				fieldWidth = widthField09;
			  	layoutChild(field, fieldWidth, subHeight);
			  	setPositionChild(field, xVal, yVal);
				xVal = xVal + fieldWidth;					
			}
					
			setExtent(xVal, subHeight);
		}
		   
		   protected boolean navigationMovement(int dx, int dy, int status, int time) {
			   System.out.println("TRM before Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
			   super.navigationMovement(dx, dy, status, time);
			   System.out.println("TRM after Current H: " + this.getHorizontalScroll() + ",V:" + this.getVerticalScroll());
			   return false;
		   }
		   
		// The preferred width of a row is defined by the list renderer.
		public int getPreferredWidth() {
			return widthField01 + widthField02 + widthField03 + widthField04 + widthField05 + widthField06 + widthField07 + widthField08 + widthField09;
		}

		// The preferred height of a row is the "row height" as defined in the
		// enclosing list.
		public int getPreferredHeight() {
			return getRowHeight();
		}
	}

	public Object get(ListField listField, int index) {
		return null;
	}

	public int getPreferredWidth(ListField listField) {
		return Display.getWidth();
	}

	public int indexOfList(ListField listField, String prefix, int start) {
		return 0;
	}

	protected boolean trackwheelClick(int status, int time)
    {
        final int index = getSelectedIndex();

        return true;
    }
}

 This shows some dummy data but if you scroll to the right and then down, you will see the view reset itself.

 

Any time you can spare to look into this would be extremely appreciated :smileyhappy: ... it's the final piece to my app and is currently the only thing delaying me getting it out the door

Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Listfield Issue

OK had a look.

 

Can't get it to work.

 

I removed everything except the vfmScreen and added the ListField to that.  It seems moving focus row on the ListField causes it to force its enclosing Manager to scroll to focus the left hand end of the row.  I have tried overriding this in navigationMovement, my changes were actioned than the movement took place anyway.

 

It is going to take someone with better knowledge and/or more time than me to get this working, if in fact it is possible to do this. 

 

Sorry.

Please use plain text.
Contributor
grendal100
Posts: 10
Registered: ‎10-30-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: Listfield Issue

Many thanks for taking the time and effort to take a look.

Given this doesn't look like it's going to be achievable, do you have any thoughts as to how this prfesentation of data could be done differently to achieve the results I require? I use TableLayout Manager for the headers, I assume this would be a good starting place for the rows too?
Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Listfield Issue

Aside from the scrolling issue, the disadvantage of the approach you have taken is the fact that you can not focus on an individual cell.   But the advantage of ListField is that it is extremely efficient for large number of rows.

 

And that is the disadvantage of TableLayoutManager.  There are two issues.  The first is that the initial load of the TableLayoutManager can take a long time as each individual cell is added to the Screen.  There are ways round this by adding them off screen.  But the second disadvantage is one that I think other people have faced, and that is scrolling seems to be compute intensive. I have never looked at this, but I presume this is because that you don't just repaint one Field, the processing has to figure out all the Fields on display and repaint all of them. 

 

But for small datasets I suspect that TableLayoutManager will work just fine. Unless you know that you are going to display 100s of cells, then I suggest you try it. 

Please use plain text.
Contributor
grendal100
Posts: 10
Registered: ‎10-30-2012
My Device: Bold 9900
My Carrier: Vodafone

Re: Listfield Issue

Focusing on an individual cell wasn't what I required which was the reason why I went for the listfield.

And I know I'm going to be displaying large quantities of data, and the amount of columns could increase over time and I don't want that to hamper performance.

I suspect that I may have to put up with the way it is now. It's not elegant, but at least it is functional.

Many thanks for all your help with this, Peter. Very very much appreciated :smileyhappy:
Please use plain text.
Developer
peter_strange
Posts: 19,595
Registered: ‎07-14-2008
My Device: Not Specified

Re: Listfield Issue

OK, but then I have one suggestion.  Instead of having one ListField, how about having one ListField per column.  I can see there will be complications because you will need to figure out how to keep the selected rows in sync. But aside from that technical issue, I think it would work and would be efficient. 

 

I would certainly look at doing this should the occasion arise. 

Please use plain text.