J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software

Using Lists

A List with a fisheye view-type.
A List displays several items which can be selected depending on it's choice type (either Choice.EXCLUSIVE, Choice.MULTIPLE or Choice.IMPLICIT).

Design

The List in the screenshot above utilizes the fisheye view-type and has been realized using the following CSS settings (without title and menubar settings):

.mainScreen {
	padding: 2;
	padding-left: 10;
	padding-right: 10;
	background {
		type: horizontal-stripes;
		first-top-color: brightBgColor;
		second-top-color: white;
		first-bottom-color: blue;
		second-bottom-color: black;
	}
	layout: horizontal-expand | horizontal-center | vertical-center;
	//#if polish.midp2
		view-type: fisheye;
		fisheyeview-scale-start: 70%;
		fisheyeview-scale-end: 40%;
		fisheyeview-alpha-start: 200;
		fisheyeview-alpha-end: 80;
		fisheyeview-remove-text: true;		
	//#endif
	//#if polish.midp2
		screen-change-animation: fade;
	//#endif
}

CSS Attributes for Lists

You can use the following CSS attributes for Lists:

CSS Attributes for List-Items

For styles of List items you can use following the CSS attributes:

Programming

Please use and import the normal javax.microedition.lcdui.List for dealing with Lists. For connecting the List and it's items with your style definitions in polish.css use style preprocessing directives:

import javax.microedition.lcdui.List;
import de.enough.polish.ui.UiAccess;

public class MenuMidlet extends MIDlet implements CommandListener {	
	List menuScreen;
	public MenuMidlet() {
		//#style mainScreen
		this.menuScreen = new List("Title", List.IMPLICIT);
		//#style mainCommand
		this.menuScreen.append( "Chat", null);
		//#style mainCommand
		this.menuScreen.append("Mail", null);
		//#style mainCommand
		this.menuScreen.append("Settings", null);
		//#style mainCommand
		this.menuScreen.append("Applications", null);
		//#style mainCommand
		this.menuScreen.append("Help", null);
		//#style mainCommand
		this.menuScreen.append("Quit", null);
		//#style mainCommand
		this.menuScreen.append("Documents", null);
		
		this.menuScreen.setCommandListener(this);
		this.menuScreen.addCommand( this.startGameCmd ); 
		this.menuScreen.addCommand( this.quitCmd );
	}
	
	public startApp() {
		Display display = Display.getDisplay(this);
		display.setCurrent( this.menuScreen );
		// pre-select Help:
		UiAccess.setCurrentListIndex( display, this.menuScreen, 4 );
	}
	
	[...]
}

For accessing J2ME Polish specific List functionalities use following static de.enough.polish.ui.UiAccess methods:

  • addItemCommand( List list, int index, Command command ): Adds a command to the specifed List item.
  • setCurrentListIndex( Display display, List list, int index ): Selects the specified List item and shows the List.
  • setListItem( List list, int index, ChoiceItem item ): Sets a de.enough.polish.ui.ChoiceItem or a subclass for the given List.
  • ChoiceItem getListItem( List list, int index ): Retrieves the specified de.enough.polish.ui.ChoiceItem from the List.
  • appendListItem( List list, ChoiceItem item ): Appends a ChoiceItem to the List.
  • setStyle(List list, int itemIndex): Sets a style for the specified List item - use this call together with a style preprocessing directive
  • setStyle(List list, int itemIndex, Style style): Sets a style programmatically for the specified List item.
  • setAttribute( List list, int index, Object key, Object value ): Sets an arbitrary attribute for the specified List item.
  • getAttribute( List list, int index, Object key ): Gets an previously set attribute value for the specified List item
  • HashMap getAttributes( List list, int index ): Retrieves all previously registered attributes from the specified List
  • setAccessible(List list, int itemIndex, boolean isAccessible): Makes a List item selectable or inaccessible - can be used with a style preprocessing directive. Make sure another List item is selected before ddeactivating a List item or call UiAccess.setCurrentListIndex() before (see above).
  • setAccessible(List list, int itemIndex, boolean isAccessible, Style style): Same as above with a programmatically selected style.
  • setVisible( List list, int index, boolean visible ): Toggles the visiblity of the specified List item. Note that you need to activate visible items by setting the preprocessing variable polish.supportInvisibleItems to true before this call can succeed.
  • boolean isVisible( List list, int index ): Determines if a List item is visible.

Configuration

You can configure if List should not show commands like "Select" for implicit and exclusive Lists or "Mark" for multiple lists. By default such commands are shown. Specify these configuration settings in the variables section of your build.xml script.

Variable  DefaultValuesExplanation
polish.List.suppressCommands false true, false Deactivates all commands.
<variable name="polish.List.suppressCommands" value="true" />
polish.List.suppressSelectCommand false true, false Deactivates the Select command for implicit and exclusive Lists.
<variable name="polish.List.suppressSelectCommand" value="true" />
polish.List.suppressMarkCommands false true, false Deactivates the Mark/Unmark commands for multiple Lists.
<variable name="polish.List.suppressMarkCommands" value="true" />

You can also change or translate the default commands used in a List with the following settings in either messages.txt or using variables in your build.xml script. For more information about translations please refer to the localization section.

# text for the 'Select' command:
polish.command.select=Choose;
# texts for'Mark' and 'Unmark' commands:
polish.command.mark=Select
polish.command.unmark=Deselect

JavaDoc

back to top