【急】,没人看的懂吗?高手注释一下下面的代码? 本帖最后由 zhq56030207 于 2010-08-25 09:43:32 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //在onUpdate中获取到fields的更新值:final String[] fields = new String[5]; fields[0] = notifyValue(update, X1); fields[1] = notifyValue(update, X2); fields[2] = notifyValue(update, X3); fields[3] = notifyValue(update, X4); fields[4] = notifyValue(update, X5);//填充消息体,并发送Message msg = messageHandler.obtainMessage(); //消息对象 msg.what = MESSAGE_HANDLE_ID_UPDATEROW_DATA;//消息标识 Bundle bundle = new Bundle();//用于存放要传递的数据 bundle.putInt(MESSAGE_KEY_ID, Integer.parseInt(itemName, 10)); bundle.putString(X1, fields[0] ); bundle.putString(X2, fields[1]); bundle.putString(X3, fields[2]); bundle.putString(X4, fields[3]); bundle.putString(X5, fields[4]); msg.setData(bundle); messageHandler.sendMessage(msg);//通过指定handler发送消息//在指定的handler中处理接受的消息:switch(msg.what) { case MESSAGE_HANDLE_ID_UPDATEROW_DATA:{//消息标识 int id = msg.getData().getInt(MESSAGE_KEY_ID);//获取传递的数据 String fields[] = new String[5]; fields[0] = msg.getData().getString(X1); fields[1] = msg.getData().getString(X2); fields[2] = msg.getData().getString(X3); fields[3] = msg.getData().getString(X4); fields[4] = msg.getData().getString(X5); updateRowInTable(id, fields);//更新表中的显示行 break; }主要是通过onupdate来监视数据更新, 然后通过handler来更新界面表中显示 // high performance public void onUpdate(int itemPos, final String itemName, UpdateInfo update) { final String[] fields = new String[5]; fields[0] = notifyValue(update, X1);其实我想知道这是干嘛的? fields[1] = notifyValue(update, X2); fields[2] = notifyValue(update, X3); fields[3] = notifyValue(update, X4); fields[4] = notifyValue(update, X5); final Runnable myUpdateResults = new Runnable() { public void run() {还有这个? updateRowInTable(Integer.parseInt(itemName, 10), fields); } }; new Thread() { public void run() { messageHandler.post(myUpdateResults); } }.start(); private Handler messageHandler = new Handler(); fields[0] = notifyValue(update, X1);//把notifyValue(update, X1)的返回值赋值到fields[0]public void run() //通过线程来更新表中的数据。 关键是Handler的消息发送 ,messageHandler.sendMessage(msg);和它对消息的处理public void handleMessage(Message msg)消息一发送 , 这么就会做出相应 其实这是一个关于android遇到ANR时,如何修改程序,如何优化程序的问题! 无论是高手还是新手都可以在MaxWit技术讨论区讨论http://linux.chinaunix.net/bbs/forum-70-1.html 如何在scrollview的顶部固定一个控件? Eclipse安装AVD遇到问题! android如何利用反射机制获取带有自定义类型参数或者返回值的函数 2011年,移动互联网加速蔓延 – 来自2011移动开发者大会 有关map用户定位 请问如何调用另外一个java页中的函数,或者说过程 不知道如何解析,求帮助 适合做课程设计的android项目 求 安卓 String类型加密解密的算法 APK获取ROOT权限后,无法运行uiautomator Jar包 如何修改RadioGroup 或 radiobuttom的样式?在线求助 音乐播放error
final String[] fields = new String[5];
fields[0] = notifyValue(update, X1);
fields[1] = notifyValue(update, X2);
fields[2] = notifyValue(update, X3);
fields[3] = notifyValue(update, X4);
fields[4] = notifyValue(update, X5);//填充消息体,并发送
Message msg = messageHandler.obtainMessage(); //消息对象
msg.what = MESSAGE_HANDLE_ID_UPDATEROW_DATA;//消息标识
Bundle bundle = new Bundle();//用于存放要传递的数据
bundle.putInt(MESSAGE_KEY_ID, Integer.parseInt(itemName, 10));
bundle.putString(X1, fields[0] );
bundle.putString(X2, fields[1]);
bundle.putString(X3, fields[2]);
bundle.putString(X4, fields[3]);
bundle.putString(X5, fields[4]);
msg.setData(bundle);
messageHandler.sendMessage(msg);//通过指定handler发送消息//在指定的handler中处理接受的消息:
switch(msg.what) {
case MESSAGE_HANDLE_ID_UPDATEROW_DATA:{//消息标识
int id = msg.getData().getInt(MESSAGE_KEY_ID);
//获取传递的数据
String fields[] = new String[5];
fields[0] = msg.getData().getString(X1);
fields[1] = msg.getData().getString(X2);
fields[2] = msg.getData().getString(X3);
fields[3] = msg.getData().getString(X4);
fields[4] = msg.getData().getString(X5);
updateRowInTable(id, fields);//更新表中的显示行
break;
}主要是通过onupdate来监视数据更新, 然后通过handler来更新界面表中显示
public void onUpdate(int itemPos, final String itemName, UpdateInfo update) {
final String[] fields = new String[5];
fields[0] = notifyValue(update, X1);其实我想知道这是干嘛的?
fields[1] = notifyValue(update, X2);
fields[2] = notifyValue(update, X3);
fields[3] = notifyValue(update, X4);
fields[4] = notifyValue(update, X5); final Runnable myUpdateResults = new Runnable() {
public void run() {还有这个?
updateRowInTable(Integer.parseInt(itemName, 10), fields);
}
};
new Thread() {
public void run() {
messageHandler.post(myUpdateResults);
}
}.start(); private Handler messageHandler = new Handler();
和它对消息的处理public void handleMessage(Message msg)
消息一发送 , 这么就会做出相应
http://linux.chinaunix.net/bbs/forum-70-1.html