A1 ………… Boolean 类
A2 ………… Byte 类
A3 ………… Integer 类
A4 ………… Float 类
A5 ………… String 类
A6 ………… Thread 类
A7 ………… System 类
A8 ………… ListView 类
D1 ………… AlertBuilder.Builder 类
DialogInterface 接口
DialogInterface.OnClickListener 接口
LayoutInflater 类
D2 ………… ProgressDialog 类
D3 ………… NotificationManager 类
D4 ………… Notification 类
D5 ………… PendingIntent 类
D6 ………… TimePickerDialog 类
D7 ………… DatePickerDialog 类
G1 ………… DecimalFormat 类
G2 ………… SimpleDateFormat 类
G3 ………… Date 类
G4 ………… Calendar 类
G5 ………… ProgressDialog 类
G6 ………… CheckBox 类
G7 ………… ProgressBar 类
G8 ………… ListView 类
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A1个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. The wrapper for the primitive type boolean
.
2. Boolean Methods:
3. Boolean Fields:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A2个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. The wrapper for the primitive type byte
.
2. Byte Methods:
3. Byte Constants:
System.out.println(Byte.decode("123")); //123 System.out.println(Byte.decode("077")); //63 System.out.println(Byte.decode("0x2F")); //47
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A3个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. The wrapper for the primitive type int
.
2. Byte Methods:
3. Byte Constants:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A4个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. The wrapper for the primitive type int
.
2. Float Constructs:
3. Byte Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A5个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. The wrapper for the primitive type int
.
2. Byte Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A6个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. The wrapper for the primitive type int
.
2. Thread Constructors:
new Thread(new Runnable(){ public void run(){ for (int i=1; i<=15; i++) { try { //---simulate doing something lengthy--- Thread.sleep(1000); //---update the dialog--- progressDialog.incrementProgressBy((int)(100/15)); } catch (InterruptedException e) { e.printStackTrace(); } } progressDialog.dismiss(); } }).start();
3. Thread Methods:
4. Thread Constants:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A7个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. Provides access to system-related information and resources including standard input and output.
2. System Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D1个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 构造一个 AlertDialog, 是 AlertDialog 的嵌套类.
2. AlertDialog.Builder Methods:
protected Dialog onCreateDialog1() { return new AlertDialog.Builder(this) .setIcon(R.drawable.ic_launcher) .setTitle("This is a dialog with some simple text...") .setMultiChoiceItems(items, itemsChecked, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int which, boolean isChecked) { Toast.makeText(getBaseContext(), items[which] + (isChecked ? " checked!":" unchecked!"), Toast.LENGTH_SHORT).show(); } } ).create(); }
※ 参考:Android 对话框(Dialog)大全 建立你自己的对话框
●·● DialogInterface 接口:对话框接口, 包括下面的嵌套类.
来源:android.content.DialogInterface
●·● DialogInterface.OnClickListener 类:对话框中的按钮被点击的处理事件.
☀☀☀<< 举例 >>☀☀☀
效果:
点击按钮实现 & 对话框方法:
public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { //点击"返回键"时触发. dialog(); } return false; }
protected void dialog(){ AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("请输入"); //标题 builder.setIcon(android.R.drawable.ic_dialog_info); //图标 builder.setView(new EditText(MainActivity.this)); //TextView builder.setPositiveButton("Yes", null); //Yes builder.setNegativeButton("No", null); //No builder.create().show(); }
效果:
XML: dialog.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dialog" android:layout_width="wrap_content" android:layout_height="match_parent" > <EditText android:layout_height="wrap_content" android:layout_width="165dip" android:id="@+id/etname" android:layout_marginRight="20dip" android:layout_alignParentRight="true" android:minWidth="100dip"/> <TextView android:layout_height="wrap_content" android:layout_width="80dip" android:textColor="#fff" android:textSize="20sp" android:layout_marginLeft="20dip" android:layout_alignBaseline="@id/etname" android:id="@+id/tvname" android:text="账号:" /> <EditText android:layout_height="wrap_content" android:layout_width="165dip" android:password="true" android:layout_marginRight="20dip" android:layout_below="@id/etname" android:layout_alignLeft="@id/etname" android:layout_alignParentRight="true" android:id="@+id/etname2" android:minWidth="100dip"/> <TextView android:layout_height="wrap_content" android:layout_width="80dip" android:textColor="#fff" android:textSize="20sp" android:layout_alignBaseline="@id/etname2" android:layout_alignLeft="@id/tvname" android:id="@+id/tvname2" android:text="密码:" /> <LinearLayout android:orientation="horizontal" android:layout_centerHorizontal="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/etname2" > <CheckBox android:id="@+id/checkBox1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#fff" android:layout_marginRight="20dip" android:checked="true" android:text="记住密码" /> <CheckBox android:id="@+id/checkBox2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#fff" android:text="自动登录" /> </LinearLayout> </RelativeLayout>
Java:
protected void dialogItem(){ AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.dialog, (ViewGroup)findViewById(R.id.dialog)); builder.setTitle("账号登陆"); builder.setIcon(android.R.drawable.ic_menu_compass); //添加系统自带图标 builder.setView(layout); //添加布局 builder.setPositiveButton("登录", null); builder.setNegativeButton("取消", null); builder.create().show(); }
●·● LayoutInflater 类:将一个 XML 文件的布局转化成 View 对象.
来源:android.view.LayoutInflater
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D2个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 带进度条的对话框, 创建实例可以返回 static ProgressDialog 的 show 方法实现.
2. ProgressDialog Methods:
new Thread(new Runnable(){ public void run(){ for (int i=1; i<=15; i++) { try { //---simulate doing something lengthy--- Thread.sleep(1000); //---update the dialog--- progressDialog.incrementProgressBy((int)(100/15)); } catch (InterruptedException e) { e.printStackTrace(); } } progressDialog.dismiss(); } }).start();
public void onClick2(View v) { //---show the dialog--- final ProgressDialog dialog = ProgressDialog.show( this, "Doing something", "Please wait...", true , true, new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { // TODO Auto-generated method stub Toast.makeText(DialogActivity.this, "gaha", Toast.LENGTH_SHORT).show(); } }); new Thread(new Runnable(){ public void run(){ try { //---simulate doing something lengthy--- Thread.sleep(10000); //---dismiss the dialog--- dialog.dismiss(); } catch (InterruptedException e) { e.printStackTrace(); } } }).start(); }
※ 参考:Android学习笔记之ProgressDialog
※ 参考:android.Dialogs
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D3个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. Class to notify the user of events that happen. This is how you tell the user that something has happened in the background.
2. NotificationManager Constructors:
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
3. NotificationManager Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D4个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. A class that represents how a persistent notification is to be presented to the user using the NotificationManager
.
2. Notification Constructors:
3. Notification Methods:
4. Notification Fields:
notif.vibrate = new long[] { 100, 250, 100, 500};
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D5个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. A description of an Intent and target action to perform with it.
2. PendingIntent Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D6个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. A dialog that prompts the user for the time of day using a TimePicker
.
2. TimePickerDialog Constructors:
TimePickerDialog timePickerDialog = new TimePickerDialog( this, new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minuteOfHour) { // TODO Auto-generated method stub yr = view.getCurrentHour(); month = view.getCurrentMinute(); hour = hourOfDay; minute = minuteOfHour; SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm aa"); Date date = new Date(0,0,0, hour, minute); String strDate = timeFormat.format(date); Toast.makeText(getBaseContext(),"You have selected " + strDate, Toast.LENGTH_SHORT).show(); } }, 10, 10, true);
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第D6个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. A simple dialog containing an DatePicker
.
2. DatePickerDialog Constructors:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G1个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 小数格式.
2. DecimalFormat Constructors:
3. DecimalFormat Methods:
※ 参考:DecimalFormat的用法
※ 参考:DecimalFormat的用法介绍
Symbol | Location | Localized? | Meaning |
---|---|---|---|
0 |
Number | Yes | 数字. |
@ |
Number | No | 有效数字. |
# |
Number | Yes | 数字, 前面的 0 不显示. |
. |
Number | Yes | 小数分隔符. |
- |
Number | Yes | 负号. |
, |
Number | Yes | 分组符, 逗号. |
E |
Number | Yes | 科学技术法, 指数. |
+ |
Exponent | Yes | 正号. |
; |
Subpattern boundary | Yes | 分隔正数和负数子模式. |
% |
Prefix or suffix | Yes | 乘以 100 并显示为百分数. |
‰ (\u2030 ) |
Prefix or suffix | Yes | 乘以 1000 并显示为千分数. |
¤ (\u00A4 ) |
Prefix or suffix | No | 货币记号,由货币符号替换。如果两个同时出现,则用国际货币符号替换。如果出现在某个模式中,则使用货币小数分隔符,而不使用小数分隔符。 |
' |
Prefix or suffix | No | 用于在前缀或或后缀中为特殊字符加引号,例如 "'#'#" 将 123 格式化为 "#123" 。要创建单引号本身,请连续使用两个单引号:"# o''clock" 。 |
* |
Prefix or suffix boundary | Yes | NEW Pad escape, precedes pad character. |
有效数字显示, 最小的有效数字个数用'@'表示, 最大的有效数字个数用'@'和'#'的和来表示
Pattern | Minimum significant digits | Maximum significant digits | Number | Output of format() |
---|---|---|---|---|
@@@ |
3 | 3 | 12345 | 12300 |
@@@ |
3 | 3 | 0.12345 | 0.123 |
@@## |
2 | 4 | 3.14159 | 3.142 |
@@## |
2 | 4 | 1.23004 | 1.23 |
pattern | value | Output of format() |
0.0 | 1234.5678 | 1234.6 |
00000.000 kg | 1234.5678 | 01234.568 kg |
##000.000 kg | 1234.5678 | 1234.568 kg |
-000.000 | 1234.5678 | -1234.568 |
-0,000.0# | 1234.5678 | -1,234.57 |
0.00E000 | 1234.5678 | 1.23E003 |
0.00% | 1234.5678 | 123456.79% |
0.00/u2030 | 1234.5678 | 1234567.89‰ |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G2个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 简单的日期格式. 将日期转换为 String 类型.
2. SimpleDateFormat Constructors:
yyyy-MM-dd 1970-01-01 yyyy-MM-dd HH:mm 1970-01-01 00:00 yyyy-MM-dd HH:mm:ss.SSSZ 1970-01-01 00:00:00.000+0000
3. SimpleDateFormat Methods:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G2个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 日期.
2. Date Constructors:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G3个 ╠══════════════════════════════════════════════════╣
╚════════╝
1. 日历.
Calendar rightNow = Calendar.getInstance()
2. Calendar Methods:
3. Calendar Constants: