View Single Post
Old 02-27-2009, 02:46 AM   #3 (permalink)
icess
New Member
 
Join Date: Feb 2009
Model: 8320
PIN: N/A
Carrier: china mobile
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I change the navigationMovement mothed , set the manager scroll value to scroll the screen . now can display the selected row. But I donot think this's a good solution. Does anyone have a better solution for this?

the code:
Code:
protected boolean navigationMovement(int dx, int dy, int status, int time) {
			Manager manager = getManager();
			XYRect xyrect = this.getExtent();
			
			if ((status&KeypadListener.STATUS_FOUR_WAY) == KeypadListener.STATUS_FOUR_WAY) { 
				if (dx > 0) {
					xoffset -= 10;
					invalidate();
					return true;
				} else if (dx < 0) {
					xoffset += 10;
					invalidate();
					if(xoffset > 0) {
						xoffset = 0;
						return true;
					}
				} else if (dy > 0) {
					if(selectedRowIndex < this.rowNum) {
						selectedRowIndex ++;
						if(selectedRowIndex == rowNum) {
							selectedRowIndex = rowNum-1;
							return false;
						}
						int rowYPosition = xyrect.y + verticalPadding+headerHeight+rowHeight*selectedRowIndex+rowHeight;
						int visiableLastY = manager.getVerticalScroll()+manager.getVisibleHeight();
						if(rowYPosition > visiableLastY) {// 
							manager.setVerticalScroll(getManager().getVerticalScroll()+rowHeight);
						}
						invalidate();
						return true;
					}
				} else if (dy < 0) {
					if(selectedRowIndex > 0) {
						selectedRowIndex --;
						if(selectedRowIndex < 0) {
							selectedRowIndex = 0;
							return false;
						}
						int rowYPosition = xyrect.y + verticalPadding+headerHeight+rowHeight*selectedRowIndex;
						int visiableLastY = manager.getVerticalScroll();
						if(rowYPosition < visiableLastY) { 
							manager.setVerticalScroll(getManager().getVerticalScroll()-rowHeight);
						}
						invalidate();
						return true;
					}
				}
			}  
			return super.navigationMovement(dx, dy, status, time);
		}
Offline   Reply With Quote