Home | History | Annotate | Download | only in ui
      1 page.title=
      2 parent.title= 
      3 parent.link=index.html
      4 @jd:body
      5 
      6 <div id="qv-wrapper">
      7 <div id="qv">
      8   <h2></h2>
      9   <ol>
     10     <li><a href="#EventListeners"></a></li>
     11     <li><a href="#EventHandlers"> </a></li>
     12     <li><a href="#TouchMode"></a></li>
     13     <li><a href="#HandlingFocus"></a></li>
     14   </ol>
     15 
     16 </div>
     17 </div>
     18 
     19 <p>Android   View 
     20 
     21 View </p>
     22 
     23 <p> View UI   
     24    Android 
     25  <code>onTouchEvent()</code> 
     26 
     27  View 
     28 View 
     29 <a href="#EventListeners"></a>UI 
     30 </p>
     31 
     32 <p>  View 
     33  {@link android.widget.Button} 
     34 
     35 <a href="#EventHandlers"> </a>
     36 </p>
     37 
     38 
     39 <h2 id="EventListeners"></h2>
     40 
     41 <p>  1  {@link android.view.View} 
     42  UI Android 
     43 </p>
     44 
     45 <p>  </p>
     46 
     47 <dl>
     48   <dt><code>onClick()</code></dt>
     49     <dd>{@link android.view.View.OnClickListener}  
     50 
     51 
     52 </dd>
     53   <dt><code>onLongClick()</code></dt>
     54     <dd>{@link android.view.View.OnLongClickListener}  1 
     55 
     56 
     57 </dd>
     58   <dt><code>onFocusChange()</code></dt>
     59     <dd>{@link android.view.View.OnFocusChangeListener}  
     60 </dd>
     61   <dt><code>onKey()</code></dt>
     62     <dd>{@link android.view.View.OnKeyListener}  
     63 </dd>
     64   <dt><code>onTouch()</code></dt>
     65     <dd>{@link android.view.View.OnTouchListener} 
     66 
     67 </dd>
     68   <dt><code>onCreateContextMenu()</code></dt>
     69     <dd>{@link android.view.View.OnCreateContextMenuListener}  
     70  <a href="{@docRoot}guide/topics/ui/menus.html#context-menu"></a> 
     71 
     72 </dd>
     73 </dl>
     74 
     75 <p> <code>View.set...Listener()</code> 
     76 
     77 
     78 : <code>{@link android.view.View#setOnClickListener(View.OnClickListener) setOnClickListener()}</code> {@link android.view.View.OnClickListener OnClickListener} 
     79 
     80 </p>
     81 
     82 <p> on-click  </p>
     83 
     84 <pre>
     85 // Create an anonymous implementation of OnClickListener
     86 private OnClickListener mCorkyListener = new OnClickListener() {
     87     public void onClick(View v) {
     88       // do something when the button is clicked
     89     }
     90 };
     91 
     92 protected void onCreate(Bundle savedValues) {
     93     ...
     94     // Capture our button from layout
     95     Button button = (Button)findViewById(R.id.corky);
     96     // Register the onClick listener with the implementation above
     97     button.setOnClickListener(mCorkyListener);
     98     ...
     99 }
    100 </pre>
    101 
    102 <p>OnClickListener 
    103 </p>
    104 <pre>
    105 public class ExampleActivity extends Activity implements OnClickListener {
    106     protected void onCreate(Bundle savedValues) {
    107         ...
    108         Button button = (Button)findViewById(R.id.corky);
    109         button.setOnClickListener(this);
    110     }
    111 
    112     // Implement the OnClickListener callback
    113     public void onClick(View v) {
    114       // do something when the button is clicked
    115     }
    116     ...
    117 }
    118 </pre>
    119 
    120 <p> <code>onClick()</code>  
    121 
    122 </p>
    123 <ul>
    124   <li><code>{@link android.view.View.OnLongClickListener#onLongClick(View) onLongClick()}</code> - 
    125 <em>true</em>  on-click <em>false</em> 
    126 
    127 
    128 </li>
    129   <li><code>{@link android.view.View.OnKeyListener#onKey(View,int,KeyEvent) onKey()}</code> - 
    130 
    131     <em>true</em>  on-key <em>false</em> 
    132 
    133 </li>
    134   <li><code>{@link android.view.View.OnTouchListener#onTouch(View,MotionEvent) onTouch()}</code> - 
    135 
    136    <em>false</em> 
    137 
    138    
    139 </li>
    140 </ul>
    141 
    142 <p>  
    143  <code>{@link android.view.View#dispatchKeyEvent(KeyEvent)
    144 dispatchKeyEvent()}</code> 
    145 <code>{@link android.app.Activity#onKeyDown(int,KeyEvent) onKeyDown()}</code>  <code>{@link android.app.Activity#onKeyUp(int,KeyEvent) onKeyUp()}</code> 
    146 
    147 </p>
    148 
    149 <p>
    150 <code>{@link android.app.Activity#onKeyDown(int,KeyEvent) onKeyDown()}</code> <strong></strong>
    151 
    152   UI 
    153 
    154  {@link android.view.inputmethod.EditorInfo#IME_ACTION_DONE}  UI 
    155 
    156 
    157 </p>
    158 
    159 <p class="note"><strong>:</strong> Android   
    160  <em>true</em>  
    161 
    162 <em>true</em> </p>
    163 
    164 
    165 <h2 id="EventHandlers"> </h2>
    166 
    167 <p>    <a href="{@docRoot}guide/topics/ui/custom-components.html"> </a>
    168 
    169 
    170 
    171 </p>
    172 <ul>
    173   <li><code>{@link  android.view.View#onKeyDown}</code> - </li>
    174   <li><code>{@link  android.view.View#onKeyUp}</code> -   </li>
    175   <li><code>{@link  android.view.View#onTrackballEvent}</code> -   </li>
    176   <li><code>{@link  android.view.View#onTouchEvent}</code> -   </li>
    177   <li><code>{@link  android.view.View#onFocusChanged}</code> - </li>
    178 </ul>
    179 <p>View 
    180 
    181 </p>
    182 <ul>
    183   <li><code>{@link  android.app.Activity#dispatchTouchEvent(MotionEvent)
    184     Activity.dispatchTouchEvent(MotionEvent)}</code> - {@link android.app.Activity} 
    185 </li>
    186   <li><code>{@link  android.view.ViewGroup#onInterceptTouchEvent(MotionEvent)
    187     ViewGroup.onInterceptTouchEvent(MotionEvent)}</code> - {@link android.view.ViewGroup} 
    188 </li>
    189   <li><code>{@link  android.view.ViewParent#requestDisallowInterceptTouchEvent(boolean)
    190     ViewParent.requestDisallowInterceptTouchEvent(boolean)}</code> - <code>{@link 
    191     android.view.ViewGroup#onInterceptTouchEvent(MotionEvent)}</code> 
    192 </li>
    193 </ul>
    194 
    195 <h2 id="TouchMode"></h2>
    196 <p>
    197  
    198 
    199 
    200 
    201 
    202  
    203 </p>
    204 <p>
    205 
    206  {@link android.view.View#isFocusableInTouchMode}  true on-click 
    207 
    208 
    209 
    210 </p>
    211 <p>
    212 
    213  
    214 
    215 </p>
    216 <p>
    217 {@link android.view.View#isInTouchMode} 
    218 
    219 
    220 </p>
    221 
    222 
    223 <h2 id="HandlingFocus"></h2>
    224 
    225 <p>
    226 
    227 <code>{@link android.view.View#isFocusable()}</code> 
    228 <code>{@link android.view.View#setFocusable(boolean) setFocusable()}</code> 
    229 <code>{@link android.view.View#isFocusableInTouchMode()}</code> <code>{@link android.view.View#setFocusableInTouchMode(boolean) setFocusableInTouchMode()}</code> 
    230 
    231 
    232 </p>
    233 
    234 <p>
    235 
    236   
    237 
    238 <var>nextFocusDown</var> <var>nextFocusLeft</var> <var>nextFocusRight</var>
    239 <var>nextFocusUp</var>  XML <em></em>
    240 <em></em> ID 
    241 </p>
    242 <pre>
    243 &lt;LinearLayout
    244     android:orientation="vertical"
    245     ... >
    246   &lt;Button android:id="@+id/top"
    247           android:nextFocusUp="@+id/bottom"
    248           ... />
    249   &lt;Button android:id="@+id/bottom"
    250           android:nextFocusDown="@+id/top"
    251           ... />
    252 &lt;/LinearLayout>
    253 </pre>
    254 
    255 <p>1 2 
    256 1  1  
    257  <var>nextFocusUp</var>  
    258 </p>
    259 
    260 <p>UI  <code>android:focusable</code> XML  
    261 
    262  <var>true</var> <code>android:focusableInTouchMode</code> 
    263 </p>
    264 <p><code>{@link android.view.View#requestFocus()}</code> </p>
    265 <p> <a href="#EventListeners"></a> <code>{@link android.view.View.OnFocusChangeListener#onFocusChange(View,boolean) onFocusChange()}</code> 
    266 
    267 </p>
    268 
    269 
    270 
    271 <!--
    272 <h2 is="EventCycle">Event Cycle</h2>
    273    <p>The basic cycle of a View is as follows:</p>
    274    <ol>
    275     <li>An event comes in and is dispatched to the appropriate View. The View
    276     handles the event and notifies any listeners.</li>
    277     <li>If, in the course of processing the event, the View's bounds may need
    278     to be changed, the View will call {@link android.view.View#requestLayout()}.</li>
    279     <li>Similarly, if in the course of processing the event the View's appearance
    280     may need to be changed, the View will call {@link android.view.View#invalidate()}.</li>
    281     <li>If either {@link android.view.View#requestLayout()} or {@link android.view.View#invalidate()} were called,
    282     the framework will take care of measuring, laying out, and drawing the tree
    283     as appropriate.</li>
    284    </ol>
    285    
    286    <p class="note"><strong>Note:</strong> The entire View tree is single threaded. You must always be on
    287    the UI thread when calling any method on any View.
    288    If you are doing work on other threads and want to update the state of a View
    289    from that thread, you should use a {@link android.os.Handler}.
    290    </p>
    291 -->
    292