⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.java

📁 j2me is based on j2mepolish, client & server for mobile application. menu sample
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		//#ifdef polish.css.show-text-in-title
			//# if (this.showTextInTitle){
				//# this.titles.clear();
			//# }
		//#endif
		this.choiceGroup.deleteAll();
		if (this.listType == IMPLICIT && this.selectCommand != null) {
			super.removeCommand( this.selectCommand );
		} else {
			removeItemCommands(this.choiceGroup);
		}
	}

	/**
	 * Gets a boolean value indicating whether this element is selected.
	 * 
	 * @param elementNum index to element to be queried
	 * @return selection state of the element
	 * @throws IndexOutOfBoundsException if elementNum is invalid
	 * @see Choice#isSelected(int) in interface Choice
	 */
	public boolean isSelected(int elementNum)
	{
		return this.choiceGroup.isSelected(elementNum);
	}

	/**
	 * Returns the index number of an element in the <code>List</code>
	 * that is selected.
	 * 
	 * @return index of selected element, or -1 if none is selected
	 * @see Choice#getSelectedIndex() in interface Choice
	 * @see #setSelectedIndex(int, boolean)
	 */
	public int getSelectedIndex()
	{
		return this.choiceGroup.getSelectedIndex();
	}

	/**
	 * Queries the state of a <code>List</code> and returns the
	 * state of all elements in the boolean array
	 * <code>selectedArray_return</code>.
	 * 
	 * @param selectedArray_return array to contain the results
	 * @return the number of selected elements in the Choice
	 * @throws IllegalArgumentException if selectedArray_return is shorter than the size of the List
	 * @throws NullPointerException if selectedArray_return is null
	 * @see Choice#getSelectedFlags(boolean[]) in interface Choice
	 * @see #setSelectedFlags(boolean[])
	 */
	public int getSelectedFlags(boolean[] selectedArray_return)
	{
		return this.choiceGroup.getSelectedFlags(selectedArray_return);
	}

	/**
	 * Sets the selected state of an element.
	 * 
	 * @param elementNum the index of the element, starting from zero
	 * @param selected the state of the element, where true means selected and false means not selected
	 * @throws IndexOutOfBoundsException if elementNum is invalid
	 * @see #setSelectedIndex(int, boolean) in interface Choice
	 * @see #getSelectedIndex()
	 */
	public void setSelectedIndex(int elementNum, boolean selected)
	{
		this.choiceGroup.setSelectedIndex(elementNum, selected);
	}

	/**
	 * Sets the selected state of all elements of the <code>List</code>.
	 * 
	 * @param selectedArray an array in which the method collect the selection status
	 * @throws IllegalArgumentException if selectedArray is shorter than the size of the List
	 * @throws NullPointerException if selectedArray is null
	 * @see #setSelectedFlags(boolean[]) in interface Choice
	 * @see #getSelectedFlags(boolean[])
	 */
	public void setSelectedFlags(boolean[] selectedArray)
	{
		this.choiceGroup.setSelectedFlags(selectedArray);
	}

	/**
	 * The same as <A HREF="../../../javax/microedition/lcdui/Displayable.html#removeCommand(javax.microedition.lcdui.Command)"><CODE>Displayable.removeCommand</CODE></A>
	 * but with the following additional semantics.
	 * 
	 * <p>If the command to be removed happens to be the select command, the
	 * <code>List</code> is set to have no select command, and the command is
	 * removed from the <code>List</code>.</p>
	 * 
	 * <p>The following code: </P>
	 * <TABLE BORDER="2">
	 * <TR>
	 * <TD ROWSPAN="1" COLSPAN="1">
	 * <pre><code>
	 * // Command c is the select command on List list
	 * list.removeCommand(c);     </code></pre>
	 * </TD>
	 * </TR>
	 * </TABLE>
	 * <P>
	 * is equivalent to the following code: </P>
	 * <TABLE BORDER="2">
	 * <TR>
	 * <TD ROWSPAN="1" COLSPAN="1">
	 * <pre><code>
	 * // Command c is the select command on List list
	 * list.setSelectCommand(null);
	 * list.removeCommand(c);     </code></pre>
	 * </TD>
	 * </TR>
	 * </TABLE>
	 * 
	 * @param cmd - the command to be removed
	 * @see javax.microedition.lcdui.Displayable#removeCommand(javax.microedition.lcdui.Command)
	 * @since  MIDP 2.0
	 */
	public void removeCommand( Command cmd)
	{
		if (cmd == this.selectCommand) {
			this.selectCommand = null;
		}
		super.removeCommand(cmd);
	}

	/**
	 * Sets the <code>Command</code> to be used for an
	 * <code>IMPLICIT</code> <code>List</code> selection
	 * action.
	 * By default, an implicit selection of a List will result in the
	 * predefined <code>List.SELECT_COMMAND</code> being used. This
	 * behavior may be
	 * overridden by calling the <code>List.setSelectCommand()</code>
	 * method with an
	 * appropriate parameter value.  If a <code>null</code> reference
	 * is passed, this
	 * indicates that no &quot;select&quot; action is appropriate for
	 * the contents
	 * of this <code>List</code>.
	 * 
	 * <p> If a reference to a command object is passed, and
	 * it is not the special command <code>List.SELECT_COMMAND</code>, and
	 * it is not currently present on this <code>List</code> object,
	 * the command object is added to this <code>List</code> as if
	 * <code>addCommand(command)</code> had been called
	 * prior to the command being made the select command.  This
	 * indicates that this command
	 * is to be invoked when the user performs the &quot;select&quot;
	 * on an element of
	 * this <code>List</code>. </p>
	 * 
	 * <p> The select command should have a command type of
	 * <code>ITEM</code> to indicate
	 * that it operates on the currently selected object.  It is not an error
	 * if the command is of some other type.
	 * (<code>List.SELECT_COMMAND</code> has a type
	 * of <code>SCREEN</code> for historical purposes.)  For purposes
	 * of presentation and
	 * placement within its user interface, the implementation is allowed to
	 * treat the select command as if it were of type <code>ITEM</code>. </p>
	 * 
	 * <p> If the select command is later removed from the <code>List</code>
	 * with <code>removeCommand()</code>, the <code>List</code> is set to have
	 * no select command as if <code>List.setSelectCommand(null)</code> had
	 * been called.</p>
	 * 
	 * <p> The default behavior can be reestablished explicitly by calling
	 * <code>setSelectCommand()</code> with an argument of
	 * <code>List.SELECT_COMMAND</code>.</p>
	 * 
	 * <p> This method has no effect if the type of the
	 * <code>List</code> is not <code>IMPLICIT</code>. </p>
	 * 
	 * @param command the command to be used for an IMPLICIT list selection action, or null if there is none
	 * @since  MIDP 2.0
	 */
	public void setSelectCommand( Command command)
	{
		if (this.listType == IMPLICIT) {
			if (this.selectCommand != null) {
				super.removeCommand( this.selectCommand );
			}
			this.selectCommand = command;
			if (this.choiceGroup.size() > 0) {
				addCommand( command );
			}
			this.choiceGroup.setSelectCommand( command );
		}
	}

	/**
	 * Sets the application's preferred policy for fitting
	 * <code>Choice</code> element
	 * contents to the available screen space. The set policy applies for all
	 * elements of the <code>Choice</code> object.  Valid values are
	 * <CODE>Choice.TEXT_WRAP_DEFAULT</CODE>, <CODE>Choice.TEXT_WRAP_ON</CODE>,
	 * and <CODE>Choice.TEXT_WRAP_OFF</CODE>. Fit policy is a hint, and the
	 * implementation may disregard the application's preferred policy.
	 * 
	 * @param fitPolicy preferred content fit policy for choice elements
	 * @throws IllegalArgumentException if fitPolicy is invalid
	 * @see Choice#setFitPolicy(int) in interface Choice
	 * @see #getFitPolicy()
	 * @since MIDP 2.0
	 */
	public void setFitPolicy(int fitPolicy)
	{
		this.choiceGroup.setFitPolicy(fitPolicy);
	}

	/**
	 * Gets the application's preferred policy for fitting
	 * <code>Choice</code> element
	 * contents to the available screen space.  The value returned is the
	 * policy that had been set by the application, even if that value had
	 * been disregarded by the implementation.
	 * 
	 * @return one of Choice.TEXT_WRAP_DEFAULT, Choice.TEXT_WRAP_ON, or Choice.TEXT_WRAP_OFF
	 * @see Choice#getFitPolicy() in interface Choice
	 * @see #setFitPolicy(int)
	 * @since  MIDP 2.0
	 */
	public int getFitPolicy()
	{
		return this.choiceGroup.getFitPolicy();
	}

	/**
	 * Sets the application's preferred font for
	 * rendering the specified element of this <code>Choice</code>.
	 * An element's font is a hint, and the implementation may disregard
	 * the application's preferred font.
	 * 
	 * <p> The <code>elementNum</code> parameter must be within the range
	 * <code>[0..size()-1]</code>, inclusive.</p>
	 * 
	 * <p> The <code>font</code> parameter must be a valid <code>Font</code>
	 * object or <code>null</code>. If the <code>font</code> parameter is
	 * <code>null</code>, the implementation must use its default font
	 * to render the element.</p>
	 * 
	 * @param elementNum the index of the element, starting from zero
	 * @param font the preferred font to use to render the element
	 * @throws IndexOutOfBoundsException if elementNum is invalid
	 * @see Choice#setFont(int, Font) in interface Choice
	 * @see #getFont(int)
	 * @since  MIDP 2.0
	 */
	public void setFont(int elementNum, Font font)
	{
		this.choiceGroup.setFont(elementNum, font);
	}

	/**
	 * Gets the application's preferred font for
	 * rendering the specified element of this <code>Choice</code>. The
	 * value returned is the font that had been set by the application,
	 * even if that value had been disregarded by the implementation.
	 * If no font had been set by the application, or if the application
	 * explicitly set the font to <code>null</code>, the value is the default
	 * font chosen by the implementation.
	 * 
	 * <p> The <code>elementNum</code> parameter must be within the range
	 * <code>[0..size()-1]</code>, inclusive.</p>
	 * 
	 * @param elementNum the index of the element, starting from zero
	 * @return the preferred font to use to render the element
	 * @throws IndexOutOfBoundsException if elementNum is invalid
	 * @see Choice#getFont(int) in interface Choice
	 * @see #setFont(int elementNum, Font font)
	 * @since  MIDP 2.0
	 */
	public Font getFont(int elementNum)
	{
		return this.choiceGroup.getFont(elementNum);
	}


	//#ifdef polish.useDynamicStyles	
	//# /* (non-Javadoc)
	 //# * @see de.enough.polish.ui.Screen#getCssSelector()
	 //# */
	//# protected String createCssSelector() {
		//# return "list";
	//# }
	//#endif	
	
	//#ifdef polish.css.show-text-in-title
	//# /* (non-Javadoc)
	 //# * @see de.enough.polish.ui.Screen#setStyle(de.enough.polish.ui.Style)
	 //# */
	//# public void setStyle(Style style) {
		//# super.setStyle(style);
		//# Boolean showTextInTitleBool = style.getBooleanProperty(37);
		//# if (showTextInTitleBool != null) { 
			//# this.showTextInTitle = showTextInTitleBool.booleanValue();  
			//# if (this.showTextInTitle && this.titles == null) {
				//# this.titles = new ArrayList();
				//# // now remove all texts from the embedded items:
				//# Item[] items = this.choiceGroup.getItems();
				//# for (int i = 0; i < items.length; i++) {
					//# ChoiceItem item = (ChoiceItem) items[i];
					//# String text = item.getText();
					//# if (text != null) {
						//# item.setText( null );
						//# this.titles.add( text );
						//# if (i == 0) {
							//# setTitle( text );
						//# }
					//# } else {
						//# this.titles.add( "" );
					//# }
				//# }
			//# }
		//# }
	//# }
	//#endif
	
	//#ifdef polish.css.show-text-in-title
	//# /* (non-Javadoc)
	 //# * @see de.enough.polish.ui.Screen#handleKeyPressed(int, int)
	 //# */
	//# protected boolean handleKeyPressed(int keyCode, int gameAction) {
		//# boolean processed = this.choiceGroup.handleKeyPressed(keyCode, gameAction);
		//# if (processed && this.showTextInTitle) {
			//# int selectedIndex = this.choiceGroup.getSelectedIndex();
			//# if (selectedIndex != -1) {
				//# setTitle( (String) this.titles.get( selectedIndex ) ); 
			//# }
		//# }
		//# return processed;
	//# }
	//#endif
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -