- 浏览: 374233 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (269)
- FY_UML (3)
- FY_JAVA (12)
- FY_JavaScript脚本 (7)
- FY_JSP (3)
- FY_Tapestry框架 (12)
- FY_Spring框架 (3)
- FY_Manager (5)
- FY_Junit(单元测试) (3)
- SERVER (14)
- FY_Struts2框架 (3)
- FY_SVN (2)
- FY_NoSQL (2)
- FY_jquery_sir (13)
- FY_hibernate_sir (8)
- FY_设计模式_sir (6)
- FY_Extjs_sir (10)
- FY_CI_sir (5)
- FY_Oracle_sir (11)
- FY_MySql_sir (10)
- FY_Hadoop_sir (3)
- FY_SOA_sir (1)
- 中文分词技术 (1)
- FY_Android (52)
- FY_架构 (2)
- FY_PhoneGap (2)
- FY_Webstorm (5)
- FY_Sencha Touch (3)
- HTML5应用快速开发 (1)
- FY_python (0)
- HADOOP (1)
- AI (0)
最新评论
-
antao592:
楼主,HkDataSourceWrapper中的getCurr ...
结合spring jdbc 实现分表分库的数据库访问构思 -
bonait:
不错,看看我的这个怎么样www.zipin168.com
So Easy京东商城 -
chenzheng8975:
...
So Easy京东商城 -
yzhenxing:
我导入demo后少com.google.android.gms ...
google地图demo -
echoaiya:
非常感谢~~
google地图demo
--------------------------------------------CallUp.java-------------------------------------
package com.ch07.callback;
/**
*
* 项目名称:com.ch07.callback
* 类名称:CallUp
* 类描述: 打电话类
* 创建人:fy
* 创建时间:2012-11-9 下午6:28:38
* Copyright (c) 方勇-版权所有
*/
public class CallUp {
/* 打电话,回调方法 */
public void callme(OnCallBack onCallBack) {
onCallBack.execute();
}
/* 接口作为参数传递 */
public interface OnCallBack {
void execute();
}
}
--------------------------------------------TestCall.java-------------------------------------
package com.ch07.callback;
/**
*
* 场景描述:
*
* java回调函数
* 什么是回调?(What)
* 精妙比喻:我把手机号码给你,你通过手机号码联系我
* 具体解释:
* 我把我的手机号码给你,你通过电话号码打电话 联系我
* 我把我的手机号码给你,你通过电话号码发短信 联系我
* 共同的部分:
* 我把我的手机号码给你,你通过电话号码(****)联系我
* 不同的部分
* 每次在使用的时候,选择是打电话或是发短信。
* 回调都做了什么?
* 将变动与不变的代码分离,变动的代码在每次使用时确认
* 什么情况使用回调?为什么要使用回调?
* 步骤固定,但有一部分内容只有在使用的时候才能知道。
*
*/
public class TestCall {
public static void main(String[] args) {
/* 实例化电话类 */
CallUp callUp = new CallUp();
/* 拨打对方的电话,只需要知道对方的手机号码 */
callUp.callme(new CallUp.OnCallBack() {
@Override
public void execute() {
System.out.println("回调方法");
}
});
}
}
--------------------------------------------DatePickerDialog.java---------------------------------
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.app;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.DatePicker;
import android.widget.DatePicker.OnDateChangedListener;
import com.android.internal.R;
import java.util.Calendar;
/**
* A simple dialog containing an {@link android.widget.DatePicker}.
*
* <p>See the <a href="{@docRoot}resources/tutorials/views/hello-datepicker.html">Date Picker
* tutorial</a>.</p>
*/
public class DatePickerDialog extends AlertDialog implements OnClickListener,
OnDateChangedListener {
private static final String YEAR = "year";
private static final String MONTH = "month";
private static final String DAY = "day";
private final DatePicker mDatePicker;
private final OnDateSetListener mCallBack;
private final Calendar mCalendar;
private boolean mTitleNeedsUpdate = true;
/**
* The callback used to indicate the user is done filling in the date.
*/
public interface OnDateSetListener {
/**
* @param view The view associated with this listener.
* @param year The year that was set.
* @param monthOfYear The month that was set (0-11) for compatibility
* with {@link java.util.Calendar}.
* @param dayOfMonth The day of the month that was set.
*/
void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth);
}
/**
* @param context The context the dialog is to run in.
* @param callBack How the parent is notified that the date is set.
* @param year The initial year of the dialog.
* @param monthOfYear The initial month of the dialog.
* @param dayOfMonth The initial day of the dialog.
*/
public DatePickerDialog(Context context,
OnDateSetListener callBack,
int year,
int monthOfYear,
int dayOfMonth) {
this(context, 0, callBack, year, monthOfYear, dayOfMonth);
}
/**
* @param context The context the dialog is to run in.
* @param theme the theme to apply to this dialog
* @param callBack How the parent is notified that the date is set.
* @param year The initial year of the dialog.
* @param monthOfYear The initial month of the dialog.
* @param dayOfMonth The initial day of the dialog.
*/
public DatePickerDialog(Context context,
int theme,
OnDateSetListener callBack,
int year,
int monthOfYear,
int dayOfMonth) {
super(context, theme);
mCallBack = callBack;
mCalendar = Calendar.getInstance();
Context themeContext = getContext();
setButton(BUTTON_POSITIVE, themeContext.getText(R.string.date_time_done), this);
setIcon(0);
LayoutInflater inflater =
(LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.date_picker_dialog, null);
setView(view);
mDatePicker = (DatePicker) view.findViewById(R.id.datePicker);
mDatePicker.init(year, monthOfYear, dayOfMonth, this);
updateTitle(year, monthOfYear, dayOfMonth);
}
public void onClick(DialogInterface dialog, int which) {
tryNotifyDateSet();
}
public void onDateChanged(DatePicker view, int year,
int month, int day) {
mDatePicker.init(year, month, day, this);
updateTitle(year, month, day);
}
/**
* Gets the {@link DatePicker} contained in this dialog.
*
* @return The calendar view.
*/
public DatePicker getDatePicker() {
return mDatePicker;
}
/**
* Sets the current date.
*
* @param year The date year.
* @param monthOfYear The date month.
* @param dayOfMonth The date day of month.
*/
public void updateDate(int year, int monthOfYear, int dayOfMonth) {
mDatePicker.updateDate(year, monthOfYear, dayOfMonth);
}
private void tryNotifyDateSet() {
if (mCallBack != null) {
mDatePicker.clearFocus();
mCallBack.onDateSet(mDatePicker, mDatePicker.getYear(),
mDatePicker.getMonth(), mDatePicker.getDayOfMonth());
}
}
@Override
protected void onStop() {
tryNotifyDateSet();
super.onStop();
}
private void updateTitle(int year, int month, int day) {
if (!mDatePicker.getCalendarViewShown()) {
mCalendar.set(Calendar.YEAR, year);
mCalendar.set(Calendar.MONTH, month);
mCalendar.set(Calendar.DAY_OF_MONTH, day);
String title = DateUtils.formatDateTime(mContext,
mCalendar.getTimeInMillis(),
DateUtils.FORMAT_SHOW_DATE
| DateUtils.FORMAT_SHOW_WEEKDAY
| DateUtils.FORMAT_SHOW_YEAR
| DateUtils.FORMAT_ABBREV_MONTH
| DateUtils.FORMAT_ABBREV_WEEKDAY);
setTitle(title);
mTitleNeedsUpdate = true;
} else {
if (mTitleNeedsUpdate) {
mTitleNeedsUpdate = false;
setTitle(R.string.date_picker_dialog_title);
}
}
}
@Override
public Bundle onSaveInstanceState() {
Bundle state = super.onSaveInstanceState();
state.putInt(YEAR, mDatePicker.getYear());
state.putInt(MONTH, mDatePicker.getMonth());
state.putInt(DAY, mDatePicker.getDayOfMonth());
return state;
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
int year = savedInstanceState.getInt(YEAR);
int month = savedInstanceState.getInt(MONTH);
int day = savedInstanceState.getInt(DAY);
mDatePicker.init(year, month, day, this);
}
}
<!--EndFragment-->
- com.ch07.callback.rar (4.4 KB)
- 下载次数: 15
发表评论
-
史上最快 Android N(安卓7.0)运行效率暴增至600%
2016-10-15 10:08 855谷歌I/O 2016开发者大会在公司总部正式拉开 ... -
So Easy京东商城
2014-12-10 16:51 1499So Easy京东商城 我和17位小伙伴们 ... -
过期Gallery取代方案horizontalscrollView之菜单导航效果
2014-03-23 16:19 2280效果 ------------------------- ... -
过期Gallery取代方案horizontalscrollView之京东效果
2014-03-23 15:57 3806效果 ------------------------- ... -
过期Gallery取代方案horizontalscrollView之幻灯片效果
2014-03-21 17:33 2569效果 ------------------------- ... -
tabhostandbadgeview
2014-03-19 13:45 976效果 -------------------------- ... -
Android优秀开源项目大全
2014-03-18 15:17 1911以下是开源项目 1、and ... -
Android分页控件xlistview
2014-03-18 14:51 1614strings.xml ----------------- ... -
过期Gallery取代方案horizontalscrollView之普通画廊
2014-03-17 22:48 2388activity_main.xml ---------- ... -
viewpage
2014-03-17 18:08 1016strings.xml ----------------- ... -
FragmentStatePagerAdapter分页
2014-03-17 17:27 746ViewPager ViewPager 如 ... -
FragmentPagerAdapter与FragmentStatePagerAdapter差异
2014-03-17 17:20 1267简介 平常使用的FragmentPagerAdapter和F ... -
抽屉菜单
2014-03-16 12:51 1782strings.xml ----------------- ... -
px和dip以及sp的区别
2014-03-08 17:01 662显示单位px和dip以及sp的区别 dip: devi ... -
fragment生命周期
2014-03-06 16:59 831Fragment必须被写成可重用的模块。因为fragmen ... -
过期API_AlertDialog
2014-03-02 10:07 1106layout----------------------- ... -
Android_Jni 操作指南
2014-01-10 14:45 901Android_Jni 操作指南 NDK(Nati ... -
各种各样圆形进度条
2013-11-11 16:30 513http://www.apkbus.com/android-1 ... -
红杏出墙__实训版
2013-04-20 18:59 1037红杏出墙__实训版 -
google地图demo
2013-04-09 14:25 3126---------------------------- ...
相关推荐
NULL 博文链接:https://fangyong2006.iteye.com/blog/1721993
ch07_android开发_源码.zip
Android範例關於所有 ListView 控制項且由淺入深
android ophone开发完全讲义源码ch07
数据库ch07数据库ch07
此资源是数电ch07_2ppt资源,适合初学者入门学习,节约大家看书的时间。
李刚老师的 《疯狂android讲义(第2版)》 源代码 第7至9章 ch07-09
Android SDK开发范例大全(第二版)CH07_2.rar
Android SDK开发范例大全(第二版)CH07_1.rar
上海交通大学出版社 徐宝林 信息系统软件设计(c#.net版)CH07代码
ch07数学运算.pdf
ch07运行环境.pptx
Ch07 产品策略.pptx
ch07 词法分析.pptx
ch07 词法分析.pdf
CH07Python模块.pptx
ch07_ibatisDemo.rar
通信电路ch07-1.ppt
ch07 商品库存管理系统,进货,出货,库存信息作了详细的实现