📄 choice.html
字号:
The <code>elementNum</code> parameter must be within the range <code>[0..size()-1]</code>, inclusive.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>elementNum</CODE> - the index of the element to be queried<DT><B>Returns:</B><DD>selection state of the element<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <code>elementNum</code> is invalid</DL>
</DD>
</DL>
<HR>
<A NAME="getSelectedIndex()"><!-- --></A><H3>
getSelectedIndex</H3>
<PRE>
public int <B>getSelectedIndex</B>()</PRE>
<DL>
<DD>Returns the index number of an element in the <code>Choice</code> that is selected. For <code>Choice</code> types <code>EXCLUSIVE</code>, <code>POPUP</code>, and <code>IMPLICIT</code> there is at most one element selected, so this method is useful for determining the user's choice. Returns <code>-1</code> if the <code>Choice</code> has no elements (and therefore has no selected elements). <p>For <code>MULTIPLE</code>, this always returns <code>-1</code> because no single value can in general represent the state of such a <code>Choice</code>. To get the complete state of a <code>MULTIPLE</code> <code>Choice</code>, see <A HREF="../../../javax/microedition/lcdui/Choice.html#getSelectedFlags(boolean[])"><CODE>getSelectedFlags</CODE></A>.</p><DD><DL>
<DT><B>Returns:</B><DD>index of selected element, or <code>-1</code> if none<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Choice.html#setSelectedIndex(int, boolean)"><CODE>setSelectedIndex(int, boolean)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getSelectedFlags(boolean[])"><!-- --></A><H3>
getSelectedFlags</H3>
<PRE>
public int <B>getSelectedFlags</B>(boolean[] selectedArray_return)</PRE>
<DL>
<DD>Queries the state of a <code>Choice</code> and returns the state of all elements in the boolean array <code>selectedArray_return</code>. <strong>Note:</strong> this is a result parameter. It must be at least as long as the size of the <code>Choice</code> as returned by <code>size()</code>. If the array is longer, the extra elements are set to <code>false</code>. <p>This call is valid for all types of <code>Choices</code>. For <code>MULTIPLE</code>, any number of elements may be selected and set to <code>true</code> in the result array. For <code>EXCLUSIVE</code>, <code>POPUP</code>, and <code>IMPLICIT</code> exactly one element will be selected (unless there are zero elements in the <code>Choice</code>). </p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>selectedArray_return</CODE> - array to contain the results<DT><B>Returns:</B><DD>the number of selected elements in the <code>Choice</code><DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>selectedArray_return</code> is shorter than the size of the <code>Choice</code>.<DD><CODE><A HREF="../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>selectedArray_return</code> is <code>null</code><DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Choice.html#setSelectedFlags(boolean[])"><CODE>setSelectedFlags(boolean[])</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setSelectedIndex(int, boolean)"><!-- --></A><H3>
setSelectedIndex</H3>
<PRE>
public void <B>setSelectedIndex</B>(int elementNum, boolean selected)</PRE>
<DL>
<DD>For <code>MULTIPLE</code>, this simply sets an individual element's selected state. <P>For <code>EXCLUSIVE</code> and <code>POPUP</code>, this can be used only to select any element, that is, the <code> selected </code> parameter must be <code> true </code>. When an element is selected, the previously selected element is deselected. If <code> selected </code> is <code> false </code>, this call is ignored. If element was already selected, the call has no effect.</P> <P>For <code>IMPLICIT</code>, this can be used only to select any element, that is, the <code> selected </code> parameter must be <code> true </code>. When an element is selected, the previously selected element is deselected. If <code> selected </code> is <code> false </code>, this call is ignored. If element was already selected, the call has no effect.</P> <P>The call to <code>setSelectedIndex</code> does not cause implicit activation of any <code>Command</code>. </P> <p>For all list types, the <code>elementNum</code> parameter must be within the range <code>[0..size()-1]</code>, inclusive. </p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>elementNum</CODE> - the index of the element, starting from zero<DD><CODE>selected</CODE> - the state of the element, where <code>true</code> means selected and <code>false</code> means not selected<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <code>elementNum</code> is invalid<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Choice.html#getSelectedIndex()"><CODE>getSelectedIndex()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setSelectedFlags(boolean[])"><!-- --></A><H3>
setSelectedFlags</H3>
<PRE>
public void <B>setSelectedFlags</B>(boolean[] selectedArray)</PRE>
<DL>
<DD>Attempts to set the selected state of every element in the <code>Choice</code>. The array must be at least as long as the size of the <code>Choice</code>. If the array is longer, the additional values are ignored. <p>For <code>Choice</code> objects of type <code>MULTIPLE</code>, this sets the selected state of every element in the <code>Choice</code>. An arbitrary number of elements may be selected. </p> <p>For <code>Choice</code> objects of type <code>EXCLUSIVE</code>, <code>POPUP</code>, and <code>IMPLICIT</code>, exactly one array element must have the value <code>true</code>. If no element is <code>true</code>, the first element in the <code>Choice</code> will be selected. If two or more elements are <code>true</code>, the implementation will choose the first <code>true</code> element and select it. </p><DD><DL>
<DT><B>Parameters:</B><DD><CODE>selectedArray</CODE> - an array in which the method collect the selection status<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>selectedArray</code> is shorter than the size of the <code>Choice</code><DD><CODE><A HREF="../../../java/lang/NullPointerException.html">NullPointerException</A></CODE> - if <code>selectedArray</code> is <code>null</code><DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Choice.html#getSelectedFlags(boolean[])"><CODE>getSelectedFlags(boolean[])</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setFitPolicy(int)"><!-- --></A><H3>
setFitPolicy</H3>
<PRE>
public void <B>setFitPolicy</B>(int fitPolicy)</PRE>
<DL>
<DD>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 <A HREF="../../../javax/microedition/lcdui/Choice.html#TEXT_WRAP_DEFAULT"><CODE>TEXT_WRAP_DEFAULT</CODE></A>, <A HREF="../../../javax/microedition/lcdui/Choice.html#TEXT_WRAP_ON"><CODE>TEXT_WRAP_ON</CODE></A>, and <A HREF="../../../javax/microedition/lcdui/Choice.html#TEXT_WRAP_OFF"><CODE>TEXT_WRAP_OFF</CODE></A>. Fit policy is a hint, and the implementation may disregard the application's preferred policy.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fitPolicy</CODE> - preferred content fit policy for choice elements<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if <code>fitPolicy</code> is invalid<DT><B>Since: </B><DD>MIDP 2.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Choice.html#getFitPolicy()"><CODE>getFitPolicy()</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getFitPolicy()"><!-- --></A><H3>
getFitPolicy</H3>
<PRE>
public int <B>getFitPolicy</B>()</PRE>
<DL>
<DD>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.<DD><DL>
<DT><B>Returns:</B><DD>one of <A HREF="../../../javax/microedition/lcdui/Choice.html#TEXT_WRAP_DEFAULT"><CODE>TEXT_WRAP_DEFAULT</CODE></A>, <A HREF="../../../javax/microedition/lcdui/Choice.html#TEXT_WRAP_ON"><CODE>TEXT_WRAP_ON</CODE></A>, or <A HREF="../../../javax/microedition/lcdui/Choice.html#TEXT_WRAP_OFF"><CODE>TEXT_WRAP_OFF</CODE></A><DT><B>Since: </B><DD>MIDP 2.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Choice.html#setFitPolicy(int)"><CODE>setFitPolicy(int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="setFont(int, javax.microedition.lcdui.Font)"><!-- --></A><H3>
setFont</H3>
<PRE>
public void <B>setFont</B>(int elementNum, <A HREF="../../../javax/microedition/lcdui/Font.html">Font</A> font)</PRE>
<DL>
<DD>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><DD><DL>
<DT><B>Parameters:</B><DD><CODE>elementNum</CODE> - the index of the element, starting from zero<DD><CODE>font</CODE> - the preferred font to use to render the element<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <code>elementNum</code> is invalid<DT><B>Since: </B><DD>MIDP 2.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Choice.html#getFont(int)"><CODE>getFont(int)</CODE></A></DL>
</DD>
</DL>
<HR>
<A NAME="getFont(int)"><!-- --></A><H3>
getFont</H3>
<PRE>
public <A HREF="../../../javax/microedition/lcdui/Font.html">Font</A> <B>getFont</B>(int elementNum)</PRE>
<DL>
<DD>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><DD><DL>
<DT><B>Parameters:</B><DD><CODE>elementNum</CODE> - the index of the element, starting from zero<DT><B>Returns:</B><DD>the preferred font to use to render the element<DT><B>Throws:</B><DD><CODE><A HREF="../../../java/lang/IndexOutOfBoundsException.html">IndexOutOfBoundsException</A></CODE> - if <code>elementNum</code> is invalid<DT><B>Since: </B><DD>MIDP 2.0</DD>
<DT><B>See Also: </B><DD><A HREF="../../../javax/microedition/lcdui/Choice.html#setFont(int, javax.microedition.lcdui.Font)"><CODE>setFont(int, javax.microedition.lcdui.Font)</CODE></A></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/Choice.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">
PREV CLASS
<A HREF="../../../javax/microedition/lcdui/CommandListener.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="Choice.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 + -