📄 item.html
字号:
<DT><B>Returns:</B><DD>a combination of layout directive values<DT><B>Since: </B><DD>MIDP 2.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Item.html#setLayout(int)"><CODE>setLayout(int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setLayout(int)"><!-- --></A><H3>
setLayout</H3>
<PRE>
public void <B>setLayout</B>(int layout)</PRE>
<DL>
<DD>Sets the layout directives for this item. <p>It is illegal to call this method if this <code>Item</code> is contained within an <code>Alert</code>.</p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>layout</CODE> - a combination of layout directive values for this item<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the value of layout is not a bit-wise OR combination of layout directives<DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if this <code>Item</code> is contained within an <code>Alert</code><DT><B>Since: </B><DD>MIDP 2.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Item.html#getLayout()"><CODE>getLayout()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="addCommand(javax.microedition.lcdui.Command)"><!-- --></A><H3>
addCommand</H3>
<PRE>
public void <B>addCommand</B>(<A HREF="../../../javax/microedition/lcdui/Command.html">Command</A> cmd)</PRE>
<DL>
<DD>Adds a context sensitive <code>Command</code> to the item. The semantic type of <code>Command</code> should be <code>ITEM</code>. The implementation will present the command only when the item is active, for example, highlighted. <p> If the added command is already in the item (tested by comparing the object references), the method has no effect. If the item is actually visible on the display, and this call affects the set of visible commands, the implementation should update the display as soon as it is feasible to do so. <p>It is illegal to call this method if this <code>Item</code> is contained within an <code>Alert</code>.</p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>cmd</CODE> - the command to be added<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if this <code>Item</code> is contained within an <code>Alert</code><DD><CODE><A HREF="../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if cmd is <code>null</code><DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="removeCommand(javax.microedition.lcdui.Command)"><!-- --></A><H3>
removeCommand</H3>
<PRE>
public void <B>removeCommand</B>(<A HREF="../../../javax/microedition/lcdui/Command.html">Command</A> cmd)</PRE>
<DL>
<DD>Removes the context sensitive command from item. If the command is not in the <code>Item</code> (tested by comparing the object references), the method has no effect. If the <code>Item</code> is actually visible on the display, and this call affects the set of visible commands, the implementation should update the display as soon as it is feasible to do so. If the command to be removed happens to be the default command, the command is removed and the default command on this Item is set to <code>null</code>. The following code: <CODE> <pre> // Command c is the default command on Item item item.removeCommand(c); </pre> </CODE> is equivalent to the following code: <CODE> <pre> // Command c is the default command on Item item item.setDefaultCommand(null); item.removeCommand(c); </pre> </CODE><DD><DL>
<DT><B>Parameters:</B><DD><CODE>cmd</CODE> - the command to be removed<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setItemCommandListener(javax.microedition.lcdui.ItemCommandListener)"><!-- --></A><H3>
setItemCommandListener</H3>
<PRE>
public void <B>setItemCommandListener</B>(<A HREF="../../../javax/microedition/lcdui/ItemCommandListener.html">ItemCommandListener</A> l)</PRE>
<DL>
<DD>Sets a listener for <code>Commands</code> to this <code>Item</code>, replacing any previous <code>ItemCommandListener</code>. A <code>null</code> reference is allowed and has the effect of removing any existing listener. <p>It is illegal to call this method if this <code>Item</code> is contained within an <code>Alert</code>.</p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>l</CODE> - the new listener, or <code>null</code>.<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if this <code>Item</code> is contained within an <code>Alert</code><DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="getPreferredWidth()"><!-- --></A><H3>
getPreferredWidth</H3>
<PRE>
public int <B>getPreferredWidth</B>()</PRE>
<DL>
<DD>Gets the preferred width of this <code>Item</code>. If the application has locked the width to a specific value, this method returns that value. Otherwise, the return value is computed based on the <code>Item's</code> contents, possibly with respect to the <code>Item's</code> preferred height if it is locked. See <a href="#sizes">Item Sizes</a> for a complete discussion.<DD><DL>
<DT><B>Returns:</B><DD>the preferred width of the Item<DT><B>Since: </B><DD>MIDP 2.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Item.html#getPreferredHeight()"><CODE>getPreferredHeight()</CODE></A>,
<A HREF="../../../javax/microedition/lcdui/Item.html#setPreferredSize(int, int)"><CODE>setPreferredSize(int, int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getPreferredHeight()"><!-- --></A><H3>
getPreferredHeight</H3>
<PRE>
public int <B>getPreferredHeight</B>()</PRE>
<DL>
<DD>Gets the preferred height of this <code>Item</code>. If the application has locked the height to a specific value, this method returns that value. Otherwise, the return value is computed based on the <code>Item's</code> contents, possibly with respect to the <code>Item's</code> preferred width if it is locked. See <a href="#sizes">Item Sizes</a> for a complete discussion.<DD><DL>
<DT><B>Returns:</B><DD>the preferred height of the <code>Item</code><DT><B>Since: </B><DD>MIDP 2.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Item.html#getPreferredWidth()"><CODE>getPreferredWidth()</CODE></A>,
<A HREF="../../../javax/microedition/lcdui/Item.html#setPreferredSize(int, int)"><CODE>setPreferredSize(int, int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setPreferredSize(int, int)"><!-- --></A><H3>
setPreferredSize</H3>
<PRE>
public void <B>setPreferredSize</B>(int width, int height)</PRE>
<DL>
<DD>Sets the preferred width and height for this <code>Item</code>. Values for width and height less than <code>-1</code> are illegal. If the width is between zero and the minimum width, inclusive, the minimum width is used instead. If the height is between zero and the minimum height, inclusive, the minimum height is used instead. <p>Supplying a width or height value greater than the minimum width or height <em>locks</em> that dimension to the supplied value. The implementation may silently enforce a maximum dimension for an <code>Item</code> based on factors such as the screen size. Supplying a value of <code>-1</code> for the width or height unlocks that dimension. See <a href="#sizes">Item Sizes</a> for a complete discussion.</p> <p>It is illegal to call this method if this <code>Item</code> is contained within an <code>Alert</code>.</p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>width</CODE> - the value to which the width should be locked, or <code>-1</code> to unlock<DD><CODE>height</CODE> - the value to which the height should be locked, or <code>-1</code> to unlock<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if width or height is less than <code>-1</code><DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if this <code>Item</code> is contained within an <code>Alert</code><DT><B>Since: </B><DD>MIDP 2.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Item.html#getPreferredHeight()"><CODE>getPreferredHeight()</CODE></A>,
<A HREF="../../../javax/microedition/lcdui/Item.html#getPreferredWidth()"><CODE>getPreferredWidth()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getMinimumWidth()"><!-- --></A><H3>
getMinimumWidth</H3>
<PRE>
public int <B>getMinimumWidth</B>()</PRE>
<DL>
<DD>Gets the minimum width for this <code>Item</code>. This is a width at which the item can function and display its contents, though perhaps not optimally. See <a href="#sizes">Item Sizes</a> for a complete discussion.<DD><DL>
<DT><B>Returns:</B><DD>the minimum width of the item<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="getMinimumHeight()"><!-- --></A><H3>
getMinimumHeight</H3>
<PRE>
public int <B>getMinimumHeight</B>()</PRE>
<DL>
<DD>Gets the minimum height for this <code>Item</code>. This is a height at which the item can function and display its contents, though perhaps not optimally. See <a href="#sizes">Item Sizes</a> for a complete discussion.<DD><DL>
<DT><B>Returns:</B><DD>the minimum height of the item<DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="setDefaultCommand(javax.microedition.lcdui.Command)"><!-- --></A><H3>
setDefaultCommand</H3>
<PRE>
public void <B>setDefaultCommand</B>(<A HREF="../../../javax/microedition/lcdui/Command.html">Command</A> cmd)</PRE>
<DL>
<DD>Sets default <code>Command</code> for this <code>Item</code>. If the <code>Item</code> previously had a default <code>Command</code>, that <code>Command</code> is no longer the default, but it remains present on the <code>Item</code>. <p>If not <code>null</code>, the <code>Command</code> object passed becomes the default <code>Command</code> for this <code>Item</code>. If the <code>Command</code> object passed is not currently present on this <code>Item</code>, it is added as if <A HREF="../../../javax/microedition/lcdui/Item.html#addCommand(javax.microedition.lcdui.Command)"><CODE>addCommand(javax.microedition.lcdui.Command)</CODE></A> had been called before it is made the default <code>Command</code>.</p> <p>If <code>null</code> is passed, the <code>Item</code> is set to have no default <code>Command</code>. The previous default <code>Command</code>, if any, remains present on the <code>Item</code>. </p> <p>It is illegal to call this method if this <code>Item</code> is contained within an <code>Alert</code>.</p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>cmd</CODE> - the command to be used as this <code>Item's</code> default <code>Command</code>, or <code>null</code> if there is to be no default command<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if this <code>Item</code> is contained within an <code>Alert</code><DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<HR>
<A NAME="notifyStateChanged()"><!-- --></A><H3>
notifyStateChanged</H3>
<PRE>
public void <B>notifyStateChanged</B>()</PRE>
<DL>
<DD>Causes this <code>Item's</code> containing <code>Form</code> to notify the <code>Item's</code> <A HREF="../../../javax/microedition/lcdui/ItemStateListener.html"><CODE>ItemStateListener</CODE></A>. The application calls this method to inform the listener on the <code>Item</code> that the <code>Item's</code> state has been changed in response to an action. Even though this method simply causes a call to another part of the application, this mechanism is useful for decoupling the implementation of an <code>Item</code> (in particular, the implementation of a <code>CustomItem</code>, though this also applies to subclasses of other items) from the consumer of the item. <p>If an edit was performed by invoking a separate screen, and the editor now wishes to "return" to the form which contained the selected <code>Item</code>, the preferred method is <code>Display.setCurrent(Item)</code> instead of <code>Display.setCurrent(Displayable)</code>, because it allows the <code>Form</code> to restore focus to the <code>Item</code> that initially invoked the editor.</p> <p>In order to make sure that the documented behavior of <code>ItemStateListener</code> is maintained, it is up to the caller (application) to guarantee that this function is not called unless:</p> <ul> <li>the <code>Item's</code> value has actually been changed, and</li> <li>the change was the result of a user action (an "edit") and NOT as a result of state change via calls to <code>Item's</code> APIs </li> </ul> <p>The call to <code>ItemStateListener.itemStateChanged</code> may be delayed in order to be serialized with the event stream. The <code>notifyStateChanged</code> method does not block awaiting the completion of the <code>itemStateChanged</code> method.</p><DD><DL>
<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalStateException.html">IllegalStateException</A></CODE> - if the <code>Item</code> is not owned by a <code>Form</code><DT><B>Since: </B><DD>MIDP 2.0</DD>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Item.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<strong>MID Profile</strong></EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../javax/microedition/lcdui/ImageItem.html"><B>PREV CLASS</B></A>
<A HREF="../../../javax/microedition/lcdui/List.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A>
<A HREF="Item.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->
<HR>
<font size="-1"><a href="mailto:midp-feedback@risc.sps.mot.com">Submit a comment or suggestion</a> Version 2.0 of MID Profile Specification<br>Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright (c) 1993-2002 Sun Microsystems, Inc. 901 San Antonio Road,Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -