本帖最后由 zhq56030207 于 2010-08-25 09:43:32 编辑

解决方案 »

  1.   

    //在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来更新界面表中显示
      

  2.   

    // 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();
      

  3.   

    fields[0] = notifyValue(update, X1);//把notifyValue(update, X1)的返回值赋值到fields[0]public void run() //通过线程来更新表中的数据。
      

  4.   

     关键是Handler的消息发送 ,messageHandler.sendMessage(msg);
    和它对消息的处理public void handleMessage(Message msg)
    消息一发送 , 这么就会做出相应
      

  5.   

    其实这是一个关于android遇到ANR时,如何修改程序,如何优化程序的问题!
      

  6.   

    无论是高手还是新手都可以在MaxWit技术讨论区讨论
    http://linux.chinaunix.net/bbs/forum-70-1.html