day01- Upper- Dialog interfaces

public class

Dialog

extends   Object
implements   DialogInterface   Window.Callback   KeyEvent.Callback   View.OnCreateContextMenuListener
java.lang.Object
   ↳ android.app.Dialog
Known Direct Subclasses
AlertDialog,   AppCompatDialog,   CharacterPickerDialog,   MediaRouteChooserDialog,   Presentation
Known Indirect Subclasses
AlertDialog,   DatePickerDialog,   MediaRouteControllerDialog,   ProgressDialog,   TimePickerDialog

we all know every class  are extends Object, It's nothing special. 
so, the problem is what is    Window.Callback   ,     KeyEvent.Callback   ,    View.OnCreateContextMenuListener  

first .  Window.Callback     

public static interface

Window.Callback

android.view.Window.Callback
Known Indirect Subclasses
AccountAuthenticatorActivity,   ActionBarActivity,   Activity,   ActivityGroup,   AlertDialog,   AliasActivity,   AppCompatActivity,   AppCompatDialog, CharacterPickerDialog,   DatePickerDialog,   Dialog, and   9 others.

Class Overview

API from a Window back to its caller. This allows the client to intercept key dispatching, panels and menus, etc.


from view.Window.Callback ,  with so many Activity. almost include main content View.Like AppCompatActivity, Diaolg, Activity. God ! It's  so important but I can not believe I never touch this place.    
Here some methods. Let's check. 
abstract boolean
dispatchKeyEvent( KeyEvent  event)
Called to process key events.
abstract boolean
dispatchTouchEvent( MotionEvent  event)
Called to process touch screen events.
abstract void
onContentChanged()
This hook is called whenever the content view of the screen changes (due to a call to Window.setContentView  or   Window.addContentView).
abstract boolean
onMenuItemSelected(int featureId,   MenuItem  item)
Called when a panel's menu item has been selected by the user.
abstract void
onWindowAttributesChanged( WindowManager.LayoutParams  attrs)
This is called whenever the current window attributes change.
abstract void
onWindowFocusChanged(boolean hasFocus)
This hook is called whenever the window focus changes.
Oh !!!    that's a big trasher,Look,  dispatchKeyEvent ( KeyEvent   event), I can got everything about Screen.It's my place, and onContentChanged(), this hook is called whenever the content view of the screen changes (due to a call to Window.setContentView or Window.addContentView ).  I got U. Window.Callback  is like a part of our body. like  ears or eyes.

second .  KeyEvent.Callback 

public static interface

KeyEvent.Callback

android.view.KeyEvent.Callback
Known Indirect Subclasses
AbsListView,   AbsSeekBar,   AbsSpinner,   AbsoluteLayout,   AbstractInputMethodService,   AccountAuthenticatorActivity,   ActionBarActivity, ActionMenuView,   Activity, and   142 others.
check api I found so easy. I just want to show u about her methods.

Summary

Public Methods
abstract boolean
onKeyDown(int keyCode,   KeyEvent  event)
Called when a key down event has occurred.
abstract boolean
onKeyLongPress(int keyCode,   KeyEvent  event)
Called when a long press has occurred.
abstract boolean
onKeyMultiple(int keyCode, int count,   KeyEvent  event)
Called when multiple down/up pairs of the same key have occurred in a row.
abstract boolean
onKeyUp(int keyCode,   KeyEvent  event)
Called when a key up event has occurred.

no more words, I think I got u.  scratch  Input information.

third . View.OnCreateContextMenuListener 

public static interface

View.OnCreateContextMenuListener

android.view.View.OnCreateContextMenuListener
Known Indirect Subclasses
AccountAuthenticatorActivity,   ActionBarActivity,   Activity,   ActivityGroup,   AlertDialog,   AliasActivity,   AppCompatActivity,   AppCompatDialog, AppCompatDialogFragment,   BaseLeanbackPreferenceFragment,   BrowseFragment,   BrowseSupportFragment, and   50 others.

Class Overview

Interface definition for a callback to be invoked when the context menu for this view is being built.

Summary

Public Methods
abstract void
onCreateContextMenu( ContextMenu  menu,   View  v,   ContextMenu.ContextMenuInfo  menuInfo)
Called when the context menu for this view is being built.

Um, what ? onCreate, context, Menu, Listener ?  mix them make me pozzle. a callback to be invoked when the context  menu for thie view is being built ?  

doesn't matter. keep go on....
   

Called when the context menu for this view is being built. It is not safe to hold onto the menu after this method returns.

Parameters
menu The context menu that is being built
v The view for which the context menu is being built
menuInfo Extra information about the item for which the context menu should be shown. This information will vary depending on the class of v.

not safe. I got a doubt. why context need menu? if context is bascial element like object.It's should blanket. no menus. 

I need to know how to work like  Window.Callback and  KeyEvent.Callback  , also I need to know why context need menus?  

I'll  do this tomorrow night. It's 2016-1-18 23:28:04 . I should go bed for my work tomorrow. It's the first I write blog in English.Feel like  good. 

I'm fish, I'm on.
----jack chen

你可能感兴趣的:(api)