应用重在积累
键盘截获事件
事件:
onKeyMultiple、onTouchEvent、onKeyDown、onKeyUp、onKeyLongPress、onBackPressed
截获:
KeyEvent.KEYCODE_MENU、KeyEvent.KEYCODE_BACK、KeyEvent.KEYCODE_0、
KeyEvent.KEYCODE_DPAD_CENTER、KeyEvent.KEYCODE_DPAD_DOWN、
KeyEvent.KEYCODE_DPAD_LEFT、KeyEvent.KEYCODE_DPAD_RIGHT、
KeyEvent.KEYCODE_DPAD_UP、KeyEvent.KEYCODE_ALT_LEFT、
MotionEvent.ACTION_MOVE
Toast、Dialog、PopupWindow区别:共同点都可以加载布局,不同点是否可以获取焦点、是否可以自定义位置。
Dialog :android自带实例:com.example.android.apis.app. AlertDialogSamples
Toast : 方式一加载布局(下面红色为加载布局方式)
LayoutInflater layoutInflater = getLayoutInflater();
layoutView = (LinearLayout) layoutInflater.inflate(
R.layout.toast,
(ViewGroup) findViewById(R.id.toast_area));
toast = new Toast(getApplicationContext());
toast.setView(layoutView);
toast.show();
方式二简单提示:Toast.makeText(this, "This checkbox is: unchecked",
Toast.LENGTH_SHORT).show();
布局中拆分布局:<include layout="@layout/*** " />
针对性的布局或组件隐藏:android:visibility="gone"
代码控制setVisibility(View.VISIBLE/GONE/ INVISIBLE/GONE);
字体的HTML格式式处理:Html.fromHtml("<u>添加抄送</u>")
ScrollView:注意点:不能在之内包含ListView因为它本身也包含了、其次一定别忘了是先加载布局后在次布局上加载组件。
五大布局:
Android有五大布局对象,它们分别是FrameLayout【遮蔽】,LinearLayout【线性布局setOrientation(int) /android:orientation=” horizontal / vertical”注意:好多属性有相应的对应的方法】,RelativeLayout【相对布局】,
TableLayout【android自带实例:com.example.android.apis.view. Tabs3】
AbsoluteLayou【xy的0点坐标为左上角,绝对布局[android:layout_y="10px"、android:layout_x="110px"]】
Acivity生命周期注意点:
file:///D:/android_sdk/android-sdk-windows/docs/reference/android/app/Activity.html
· onCreate(Bundle) is where you initialize your activity. Most importantly, here you will usually callsetContentView(int) with a layout resource defining your UI, and using findViewById(int) to retrieve the widgets in that UI that you need to interact with programmatically.
· onPause() is where you deal with the user leaving your activity. Most importantly, any changes made by the user should at this point be committed (usually to the ContentProvider holding the data).
·
onActivityResult
一些常用方法:setTitle(CharSequence title)等等,需要熟悉Activity这个类,这个是与用户交互的所以需要认真认识这个类提供了哪些常用方法。