废话不说 直接代码
记录一下,以后用
//重写SimpleCursorAdapter
private class SimpleAdapters extends SimpleCursorAdapter {
MyDataBaseAdapter m_MyDataBaseAdapter;
TextView message;
String[] arr=new String[100];
int pos=0;
public SimpleAdapters(Context context, int layout, Cursor c, String[] from,
int[] to) {
super(context, layout, c, from, to);
// TODO Auto-generated constructor stub
}
@Override
public void bindView(View view, Context context, final Cursor cursor)
{
/* 构造MyDataBaseAdapter对象 */
m_MyDataBaseAdapter = new MyDataBaseAdapter(context);
/* 取得数据库对象 */
m_MyDataBaseAdapter.open();
// 绑定数据到view ,test
TextView name = (TextView) view.findViewById(R.id.ListTime);
message = (TextView) view.findViewById(R.id.ListMessage);
CheckBox check=(CheckBox)view.findViewById(R.id.CheckboxActivity);
name.setText(cursor.getString(1) + "小时 " + cursor.getString(2)
+ "分钟");
if(cursor.getString(5).equals("1"))
{
check.setChecked(true);
}else
check.setChecked(false);
// 设置tag标记行
view.setTag(cursor.getString(0));
arr[pos]=cursor.getString(0);
pos++;
message.setText(cursor.getString(3));
// + view.getTag()
super.bindView(view, context, cursor);
setViewBinder(new SimpleCursorAdapter.ViewBinder()
{
public boolean setViewValue(View view, Cursor cursor,int columnIndex) {
if (view instanceof CheckBox) {
CheckBox v = (CheckBox) view;
String src=cursor.getString(columnIndex);
if(src.equals("true")){
v.setChecked(true);
return true;
}
else if(src.equals("false")){
v.setChecked(true);
return true;
}
}
return false;
}
});
//利用miCount 获取 数据库最终一个指针的id+1;(闹钟)
miCount=cursor.getInt(0);
miCount++;
}
public View getView( final int position, View convertView,ViewGroup parent)
{
convertView = super.getView(position, convertView, parent);
final CheckBox cb= (CheckBox)convertView.findViewById(R.id.CheckboxActivity);
cb.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
NotificationInfo notification;
// TODO Auto-generated method stub
notification=new NotificationInfo();
String pal=arr[position];
findData(Integer.valueOf(pal) ,pal,notification);
UpData(pal,notification);
}
});
return convertView;
}
public void findData(int ids ,String pal,NotificationInfo notification) {
Cursor cursor = m_MyDataBaseAdapter.fetchData(ids);
if (cursor != null && cursor.getCount() >= 0)
{
notification.SetHour(Integer.valueOf(cursor.getString(1))) ;
notification.SetMinute(Integer.valueOf(cursor.getString(2)));
notification.SetMessage(cursor.getString(3));
// notification.SetMessage(":"+pal+":");
if(cursor.getString(4).equals("1"))
{
notification.SetVibrationStatus(true);
}else
{
notification.SetVibrationStatus(false);
}
notification.SetMusicName(cursor.getString(6));
notification.SetMusicPath(cursor.getString(7));
if(cursor.getString(5).equals("1"))
{
CancleAlarm(ids);
notification.SetActiveStatus(false);
}else
{
notification.SetActiveStatus(true);
StartAlarm(ids,Integer.valueOf(cursor.getString(1)),Integer.valueOf(cursor.getString(2)));
}
}
// Toast.makeText(AlarmInfo.this, "finddata"+isVibrate+":"+"activate"+activate , Toast.LENGTH_LONG).show();
}
public void UpData(String id ,NotificationInfo notification)
{
m_MyDataBaseAdapter.updateData(Integer.valueOf(id), notification);
}
}
分享到:
相关推荐
同事给我想到的一个办法是:给每个布局提前设置一个tag,也就是绑定对应需要设置的数据,在点击事件的时候,会有一个view,根据该view重新拿到这个tag,取得里面的数据,就可以了,防止错乱的问题,成功解决,大概...
注:以上三个案例,上课时会根据每个班的课堂反馈选择其中一个案例予以讲解学习。 7、如鹏网项目(9天) 查看项目演示 功能点 站内搜索、栏目管理、视频播放(完全模仿优酷视频页面)、焦点图、静态页面生成(新浪、...
以setAdapter形式注入数据,直接设置selector为background即可完成标签选则的切换,类似CheckBox,支持控制选择的Tag数量,比如:单选、多选,支持setOnTagClickListener,当点击某个Tag回调,支持setOnSelectListener,...
|--TabHost一个界面显示多Activity |--TextView单行跑马灯效果 |--TextView虚拟获得焦点 |--uploadServlet |--uri之表示资源resource |--ViewPage的使用 |--view中的tag用法之存储对象 |--view常用属性 |--xml常用...
72 <br>0102 将字符串首字母转换大写 72 <br>0103 如何进行字节数组和字符串的相互转换 72 <br>0104 如何把一个按空格分割的字符串存储在一个ArrayList数组中 73 <br>4.2 获取字符串信息 73 ...
6个目标文件,EJB来模拟银行ATM机的流程及操作:获取系统属性,初始化JNDI,取得Home对象的引用,创建EJB对象,并将当前的计数器初始化,调用每一个EJB对象的count()方法,保证Bean正常被激活和钝化,EJB对象是用...
6个目标文件,EJB来模拟银行ATM机的流程及操作:获取系统属性,初始化JNDI,取得Home对象的引用,创建EJB对象,并将当前的计数器初始化,调用每一个EJB对象的count()方法,保证Bean正常被激活和钝化,EJB对象是用...
实例033 制作一个数字猜猜看小游戏 40 实例034 使用goto语句在数组中搜索指定图书 42 第3章 字符串处理技术 44 3.1 字符及字符串转换 45 实例035 将字母全部转换为大写或小写 45 实例036 字母与ASCII码的转换 46 ...
1.2 第一个VB应用程序9 1.2.1 向窗体添加代码9 1.2.2 设置控件的属性10 1.2.3 为控件命名12 1.2.4 移动及重新调整控件尺寸13 1.2.5 设置Tab顺序13 1.2.6 添加代码14 1.2.7 运行和调试程序15 1.2.8 优化示例程序16 ...
1.2 第一个VB应用程序9 1.2.1 向窗体添加代码9 1.2.2 设置控件的属性10 1.2.3 为控件命名12 1.2.4 移动及重新调整控件尺寸13 1.2.5 设置Tab顺序13 1.2.6 添加代码14 1.2.7 运行和调试程序15 1.2.8 优化示例程序16 ...
《C#全能速查宝典》共分为8章,分别介绍了C#语言基础、Windows窗体及常用控件、Windows高级控件、控件公共属性、方法及事件、数据库开发、文件、数据流与注册表、GDI+绘图技术和C#...,每一个知识点都配有具体的示例...